Cairn

io.github.jasondostal由 GitHub 账号 jasondostal 发布v0.21.2更新于 Oct 27, 2026

Persistent memory for AI agents and humans. Store, search, and discover patterns.

发布方自己的服务:Cairn.ink Memory

已验证STDIO仅桌面知识与记忆开发者工具

概览

AI 生成的概览

自托管的持久记忆服务器,让助手跨会话、跨项目存储、搜索和回忆决策、事实与模式。

可以做什么
  • 存储、搜索和回忆记忆,融合向量、关键词、时效与标签排序,并支持时间过滤
  • 以规则、近期活动、信念和未完成工作开启会话,并管理信念与工作记忆
  • 创建、认领和完成工作项,管理项目文档
  • 执行代码结构查询(依赖方、调用方、影响范围、死代码、复杂度)并校验架构规则
  • 修改、整合和导入记忆,并记录结构化的思考序列
适用场景
适合需要助手在会话之间、跨项目记住决策与事实的场景,或希望使用自托管记忆层(可选知识图谱与代码智能)而非托管服务时。
运行要求
以本地进程(容器镜像)运行,需要带 pgvector 的 PostgreSQL,知识图谱可选 Neo4j;README 描述的是四容器 Docker Compose 部署。需要 CAIRN_DB_HOST 和密钥 CAIRN_DB_PASS;CAIRN_LLM_BACKEND 选择 ollama 或 bedrock 用于增强,属可选项。
安装前请注意
项目已停止维护、仓库转为只读归档,后继项目名为 rill,不要期待后续修复。默认数据库密码是开发用值,应予以更改。增强功能可能把记忆内容发送给 Bedrock、Gemini 或 OpenAI 等外部模型服务。认证默认关闭,README 称其未经独立审计;对外暴露前应启用认证并加上 TLS。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Cairn,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

[Cairn — persistent memory for agents and humans]

[Release] [License] [MCP] [PostgreSQL]

[!IMPORTANT] Cairn is retired, and this repository is archived (read-only). Its successor is rill — a faster, leaner, MCP-native memory server written in Go that learned from everything Cairn got right (and the things it got wrong). Cairn was the first; rill is where the work continues. This repo stays up as a read-only archive — explore it, fork it, but new development lives in rill.


A self-hosted persistent memory platform for AI agents and humans. Store something once, find it later, across sessions, across projects. Four containers. docker compose up. Done.

Cairn is the memory brain. Your agent runtime handles execution — Cairn handles knowing. What decisions were made, what facts are known, what patterns emerge across projects.

It's built for the systems person. The curious. The t-shaped. The ones who need a memory that works the way they do, across everything, all at once.

Quick Start

1. Pull and run

bash
curl -O https://raw.githubusercontent.com/jasondostal/cairn-mcp/main/docker-compose.ymldocker compose up -d

Four containers start:

  • cairn on port 8000 (MCP server + REST API)
  • cairn-ui on port 3000 (web dashboard)
  • cairn-db (PostgreSQL 16 + pgvector)
  • cairn-graph (Neo4j 5, knowledge graph)

Migrations run on first boot. Ready in about a minute.

2. Connect your IDE

Add this to your MCP config:

json
{  "mcpServers": {    "cairn": {      "type": "http",      "url": "http://localhost:8000/mcp"    }  }}

Where that goes:

IDEConfig file
Claude Code.mcp.json in your project root
Cursor.cursor/mcp.json
Windsurf.windsurf/mcp.json
ClineMCP settings panel in VS Code
Continue.continue/config.yaml
PiClaw.pi/mcp.json

Or run the setup wizard — it walks you through everything: LLM backend, database, embeddings, auth, and IDE configuration:

bash
git clone https://github.com/jasondostal/cairn-mcp.git && ./cairn-mcp/scripts/setup.sh

Pick a tier (local dev, recommended, enterprise, or custom) and the wizard collects only what that tier needs. Supports --dry-run and --non-interactive for CI.

3. Use it

Tell your agent to remember something:

"Remember that we chose PostgreSQL for storage because it handles hybrid search without a separate vector DB."

Search for it later:

"What did we decide about the storage layer?"

That's it. 11 tools available. The ones you'll use most:

ToolWhat it does
storeSave a memory with auto-enrichment. Supports event_at and valid_until for bi-temporal tracking
searchFind memories (vector + keyword + recency + tags). Temporal filters: as_of, event_after, event_before
recallGet full content for specific memory IDs
orientBoot a session with rules, recent activity, beliefs, and open work
rulesLoad behavioral guardrails (global or per-project)
beliefsDurable epistemic state — crystallize, challenge, retract knowledge with confidence tracking
work_itemsCreate, claim, and complete tasks with dependencies and gates
working_memoryCapture ephemeral thoughts — hypotheses, questions, tensions — with salience decay
projectsManage project docs (briefs, PRDs, plans)
code_queryStructural queries: dependents, impact, callers, callees, dead code, complexity, hotspots
arch_checkValidate architecture boundary rules against imports

The rest: modify, insights, think, status, consolidate, ingest.

What's in the box

Memory that persists across sessions. Your agent makes a decision at 2am. Next morning, different session, it finds that decision. That's the core. Bi-temporal tracking separates when something happened (event_at) from when you learned it (created_at). Memories that go unaccessed decay naturally; important ones are protected. Related memories get consolidated into higher-order insights automatically.

Beliefs. Durable epistemic state — knowledge held with confidence. Crystallize hypotheses into beliefs, challenge them with counter-evidence, retract them when wrong. Beliefs surface in session boot alongside rules and memories, giving agents a clear picture of what the organization knows and how confident it is.

Search that fuses signals. Vector similarity, recency, access frequency, keyword matching, and tag overlap blended via Reciprocal Rank Fusion. Filter by project, type, or time range. Temporal queries: "what did we know as of Tuesday?" via as_of, "what happened last week?" via event_after/event_before.

Knowledge graph. Entities and facts get extracted into a Neo4j graph that connects memories through shared people, places, projects, and concepts. Optional, but powerful when you're working across domains.

Thinking sequences. Structured deliberation — start with a goal, add thoughts (observations, hypotheses, analysis, alternatives), conclude. Both humans and agents contribute. The exploration itself becomes searchable memory.

Work management. Hierarchical work items with dependency tracking, gates that pause for human decisions, and activity logging. Experimental — evolving as we learn what works.

Web dashboard. Browse memories with OKLCH-colored toggle filters, score gradient bars, and shareable URL state. Explore the knowledge graph and entity relationships. View analytics, manage work items. Port 3000.

[Cairn dashboard with memory growth and token usage]
Memory growth by type, token usage tracking, and the full nav.

Code intelligence. A standalone worker indexes codebases with tree-sitter (30 languages) and builds a code graph in Neo4j. The server queries the graph without ever touching source files. Ask structural questions — "what depends on this file?", "who calls this function?", "what's the blast radius?" — and get answers from the code graph. Call graph extraction, cyclomatic complexity, dead code detection. Enforce architecture boundaries with YAML rules. Works across projects.

Supported languages (30)
CategoryLanguages
SystemsC, C++, Rust, Go, Zig
JVMJava, Scala, Kotlin, Groovy
.NETC#
ScriptingPython, Ruby, PHP, Lua, Bash
WebTypeScript/TSX, HTML, CSS
AppleSwift, Objective-C
ML/ScientificOCaml, MATLAB
Config & DataJSON, YAML, TOML, HCL (Terraform), Dockerfile, Makefile, SQL, Markdown

Multi-user authentication and RBAC. Off by default, zero to enterprise in one command. ./scripts/setup.sh includes auth configuration, or run ./scripts/setup-auth.sh standalone. Auth mode selection (none / local JWT / OIDC SSO), JWT secret generation, OIDC provider validation. Personal Access Tokens for machine clients, stdio identity for MCP. Three roles, project-level scoping, first-user-becomes-admin. Groups with OIDC sync. See the Authentication Guide.

Disaster recovery. Cron-friendly scripts for PostgreSQL dump and Neo4j graph export with configurable retention. Tested restore procedures with migration safety checks. See the Backup Guide.

Do I need an LLM?

No. Store, search, recall, and rules work without one. You lose auto-enrichment (summaries, tags, importance scoring), knowledge extraction, and thinking.

If you want enrichment:

BackendSetup
Ollama (default)Install Ollama, pull a model. Cairn connects to host.docker.internal:11434.
AWS BedrockSet CAIRN_LLM_BACKEND=bedrock, export AWS creds.
Google GeminiSet CAIRN_LLM_BACKEND=gemini, add CAIRN_GEMINI_API_KEY. Free tier available.
OpenAI-compatibleSet CAIRN_LLM_BACKEND=openai, add key. Works with OpenAI, Groq, Together, LM Studio, vLLM.

Configuration

All via environment variables. The ones that matter:

VariableDefaultWhat it does
CAIRN_PROFILE(empty)Preset: vector, enriched, knowledge, enterprise. Sets capability defaults.
CAIRN_LLM_BACKENDollamaLLM provider: ollama, bedrock, gemini, openai
CAIRN_DB_PASScairn-dev-passwordDatabase password. Change this for anything beyond local.
CAIRN_AUTH_ENABLEDfalseMulti-user authentication (JWT, PATs, OIDC/SSO)
CAIRN_AUTH_JWT_SECRET(empty)JWT signing secret (required when auth enabled)
CAIRN_OIDC_ENABLEDfalseOIDC/SSO integration (any OIDC-compliant provider)
CAIRN_MCP_OAUTH_ENABLEDfalseOAuth2 Authorization Server for remote MCP clients (Claude.ai, mobile)
CAIRN_GRAPH_BACKEND(disabled)Set to neo4j to enable knowledge graph
CAIRN_KNOWLEDGE_EXTRACTIONfalseEntity/statement extraction on store
CAIRN_EMBEDDING_BACKENDlocallocal (MiniLM, 384-dim) or bedrock (Titan V2, 1024-dim)
CAIRN_INGEST_DIR/data/ingestStaging directory for file-path ingestion of large documents
CAIRN_CODE_DIR/data/codeRoot directory for code intelligence indexing (mount codebases here)

Full reference is in docker-compose.yml. Every variable has a sensible default.

Authentication

Off by default. The fastest way to enable it is through the setup wizard:

bash
./scripts/setup.sh          # includes auth as step 2./scripts/setup-auth.sh     # or run auth setup standalone

Three modes — no auth, local JWT, or OIDC/SSO. Generates secrets, validates your identity provider's discovery endpoint, writes .env. Provider-specific URL hints for Authentik, Keycloak, Auth0, Okta, and Azure AD. Both scripts support --dry-run and --non-interactive for CI.

First user to register becomes admin. Role-based access control enforces permissions across REST API, MCP HTTP, and the web UI. Personal Access Tokens for machine clients, groups with OIDC sync.

See the Authentication Guide for the full reference covering all auth modes, OIDC provider configuration, and MCP client examples.

Security note: Cairn's auth system is functional and production-tested but has not been independently audited. For network-exposed deployments, add TLS termination and network-level access controls.

Remote MCP Access (Claude.ai, Mobile)

Connect Cairn to Claude.ai, the Claude mobile app, or any OAuth2-capable MCP client. Cairn acts as an OAuth2 Authorization Server, delegating user authentication to your existing OIDC identity provider.

Prerequisites: Auth enabled (CAIRN_AUTH_ENABLED=true), OIDC configured (CAIRN_OIDC_ENABLED=true), and a public URL set (CAIRN_PUBLIC_URL).

Enable it:

bash
CAIRN_MCP_OAUTH_ENABLED=true

Connect from Claude.ai:

  1. Go to Claude.ai Settings > Integrations > Add custom MCP
  2. Enter your Cairn URL: https://your-cairn-domain.com/mcp
  3. Claude.ai discovers the OAuth2 endpoints automatically
  4. You'll be redirected to your identity provider to log in
  5. After login, Claude.ai has full access to your Cairn MCP tools

The OAuth2 flow uses Authorization Code + PKCE with Dynamic Client Registration (RFC 7591). If your identity provider supports SSO sessions, the auth redirect is invisible after the first login.

See the Remote MCP Guide for reverse proxy configuration, security hardening, and troubleshooting.

Code Intelligence

Code intelligence runs as a standalone worker that indexes source code and writes to Neo4j. The cairn server queries the graph but never touches source files directly. This separation means indexing doesn't block the event loop and the worker can run on the machine where code lives.

Requirements: Neo4j (the cairn-graph service in docker-compose) must be running.

Quick start

bash
# Index a single project (one-shot, no watching)python -m cairn.code \  --watch /path/to/your/repo:your-project \  --neo4j-uri bolt://localhost:7687 \  --cairn-url http://localhost:8000 \  --no-watch
# Index and watch for changes (long-running)python -m cairn.code \  --watch /home/user/working/myproject:myproject \  --watch /home/user/working/other:other \  --neo4j-uri bolt://my-server:7687

Environment variables

VariableDefaultWhat it does
CAIRN_NEO4J_URIbolt://localhost:7687Neo4j bolt URI
CAIRN_NEO4J_USERneo4jNeo4j username
CAIRN_NEO4J_PASSWORDcairn-dev-passwordNeo4j password
CAIRN_API_URLhttp://localhost:8000Cairn server URL (for project ID resolution)
CAIRN_API_KEY(empty)API key if cairn auth is enabled
CAIRN_CODE_PROJECTS(empty)Comma-separated project=path pairs (alternative to --watch)
CAIRN_CODE_WATCHtrueEnable filesystem watching after initial index
CAIRN_CODE_FORCEfalseForce re-index even if content hash unchanged

Docker / remote codebases

Mount source code into the cairn container and set CAIRN_CODE_DIR:

yaml
# docker-compose.ymlvolumes:  - /path/to/code:/data/code:ro   # read-only mountenvironment:  CAIRN_CODE_DIR: /data/code

Or run the worker on the code host and point it at your cairn + Neo4j instances:

bash
CAIRN_NEO4J_URI=bolt://cairn-host:7687 \CAIRN_API_URL=http://cairn-host:8000 \CAIRN_CODE_PROJECTS="myproject=/home/user/code/myproject" \python -m cairn.code

What gets indexed

  • Symbols: functions, classes, methods, interfaces, enums, React components/hooks
  • Relationships: IMPORTS (file-level), CALLS (function-level), CONTAINS (parent-child)
  • Metadata: signatures, docstrings, cyclomatic complexity, line numbers, content hashes
  • Languages: Python, TypeScript/TSX, and 28 more (C, Rust, Go, Java, Ruby, etc.)

Query examples (via code_query MCP tool)

ActionWhat it does
dependentsFiles that import the target
dependenciesFiles the target imports
callersFunctions that call the target
calleesFunctions the target calls
call_chainTrace call paths between two functions
dead_codeFunctions with zero callers
complexityRank functions by cyclomatic complexity
impactBlast radius — transitive dependents
hotspotsPageRank — structurally important files
searchFulltext search over symbol names and docstrings

Architecture

MCP clients (Claude Code, Cursor, PiClaw)    REST clients (web UI, scripts)        |                                            |        | MCP (stdio or HTTP)                        | REST API        |                                            |+-------v--------------------------------------------v--------+|  cairn.server (MCP tools)     cairn.api (FastAPI endpoints) ||                                                             ||  core: memory, search, enrichment, extraction, clustering   ||        working memory, beliefs, thinking, work items        ||                                                             ||  embedding: local (MiniLM) or Bedrock (Titan V2)            ||  llm: Ollama, Bedrock, Gemini, OpenAI-compatible            |+------+----------------------------------------------+------++       |                                              |       |       v                                              v       |  PostgreSQL 16 + pgvector                    Neo4j 5 <-------+                                             (optional)       |                                                ^             |  code worker (python -m cairn.code)            |             |  tree-sitter parsing, call graph      --------+             |  watches filesystem for changes                             |

Benchmark

Tested against LoCoMo, a long-conversation memory benchmark with 1,986 questions across five categories.

SystemScoreLLM
Cairn81.6%Llama-3.3-70B
Human baseline87.9%—
Letta/MemGPT74.0%GPT-4o-mini
Mem066.9%GPT-4o

Test configuration: Titan V2 embeddings (Bedrock, 1024-dim), episodic ingestion (raw turns + two-pass fact extraction), Search V2 with graph-primary retrieval, type routing, cross-encoder reranking, LLM-as-judge evaluation. Full results and methodology in eval/.

Development

bash
git clone https://github.com/jasondostal/cairn-mcp.gitcd cairn-mcpcp .env.example .envdocker compose up -d --build

Status

Cairn is under active development. It's a real system used daily in production, and it's evolving as I learn what actually works for agent memory. Migrations handle schema changes. If something breaks, open an issue.

License

GNU General Public License v3.0

来源:README.md,提交 40be32a

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v0.21.2最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分

其他 Cairn 集成