Codemem
A standalone Rust memory engine for AI coding assistants. Single binary, zero runtime deps.
接入你的智能体
从发布者处安装。不是 PlugMCP 端点。
远程 URL 还是本机命令? 两种安装方式的区别
Codemem stores what your AI assistant discovers -- files read, symbols searched, edits made -- so repositories don't need re-exploring across sessions. Optionally enriches the graph with compiler-grade cross-references via SCIP indexers.

Your AI assistant explores 50 files, traces call chains, makes architectural decisions -- then the session ends. Next session? It starts from scratch. Every. Single. Time.
Worse: it edits UserService.validate() without knowing that 47 downstream functions depend on that return type. It refactors a module with no memory of why the previous approach was chosen.
The assistant needs a knowledge graph -- not more text.
Codemem builds a persistent, queryable knowledge graph of your codebase and your assistant's interactions with it. Commits become nodes. Symbols have typed edges. Decisions leave traces. And your assistant picks up exactly where it left off.
# One command. That's it.
cd your-project && codemem init
From that point on, Codemem silently captures context, injects prior knowledge at session start, and provides 32 MCP tools to your assistant -- including temporal queries, diff review, and blast radius analysis.
# Shell (macOS/Linux)
curl -fsSL https://raw.githubusercontent.com/cogniplex/codemem/main/install.sh | sh
# Homebrew
brew install cogniplex/tap/codemem
# Cargo
cargo install codemem
Or download a prebuilt binary from Releases.
cd your-project
codemem init
Downloads the local embedding model (~440MB, one-time), registers lifecycle hooks, and configures the MCP server for your AI assistant. Automatically detects Claude Code, Cursor, and Windsurf.
Codemem now automatically captures context, injects prior knowledge at session start, and provides 32 MCP tools to your assistant.
Run the full analysis pipeline -- indexes your codebase with tree-sitter, enriches the graph with SCIP cross-references (if indexers are installed), computes PageRank, and detects architectural clusters:
codemem analyze
Then launch the code-mapper agent to do deep, agent-driven analysis -- it spawns a team of specialized agents that traverse the knowledge graph, discover patterns, and store architectural insights:
claude --agent code-mapper
See Index & Enrich Pipeline for what happens under the hood.
SCIP (Source Code Intelligence Protocol) gives codemem compiler-grade cross-references -- every call, import, type reference, and override in your codebase, with zero false positives. codemem analyze auto-detects installed indexers and runs them automatically.
Install the indexer for your language:
Codemem detects languages from manifest files (Cargo.toml, package.json, pyproject.toml, go.mod, etc.) and checks PATH for the corresponding indexer. If found, SCIP edges are fused with ast-grep pattern edges -- when both sources agree on the same edge, their confidence scores sum (0.10 + 0.15 = 0.25), producing higher-fidelity graph connections.
Configure via ~/.codemem/config.toml:
[scip]
enabled = true # Master switch (default: true)
auto_detect_indexers = true # Check PATH for available indexers
cache_index = true # Cache .scip files between runs
cache_ttl_hours = 24 # Re-index if cache older than this
create_external_nodes = true # Create ext: nodes for dependency symbols
store_docs_as_memories = true # Attach hover docs as memories
hierarchical_containment = true # Build nested containment tree
collapse_intra_class_edges = true # Fold intra-class calls into parent metadata
[scip.fan_out_limits]
module = 200 # Modules can be widely imported
class = 50 # Classes referenced moderately
function = 30 # Functions and methods less so
method = 30
# Override auto-detected indexer commands per language:
# [scip.indexers]
# rust = "rust-analyzer scip ."
# typescript = "scip-typescript index --infer-tsconfig"
No SCIP indexer installed? No problem -- codemem works fine without it. You just get ast-grep pattern edges (confidence 0.10) instead of compiler-grade ones.
Pipe a diff through codemem review and get a full blast radius analysis -- changed symbols mapped to direct and transitive dependents, risk scores, and potentially missing changes -- before you merge.
git diff main..HEAD | codemem review --format text
Risk Score: 7.2 (high)
Changed Symbols: 3
sym:AuthService::validate (PageRank: 0.032)
sym:AuthService::refresh (PageRank: 0.018)
sym:TokenStore::revoke (PageRank: 0.011)
Direct Dependents: 12
Transitive Dependents: 47
Potentially Missing Changes:
sym:SessionMiddleware::check — calls validate(), may need update
Also available as the review_diff MCP tool for in-assistant use.
Every commit becomes a node in the graph. Query what changed, when, and what drifted:
# "What changed in the last two weeks?"
# → MCP tool: what_changed(from, to)
# "Show me the graph as it was on March 1st"
# → MCP tool: graph_at_time(at)
# "Which high-centrality files haven't been touched in 90 days?"
# → MCP tool: find_stale_files(stale_days=90)
# "Detect architectural drift between Q1 and Q2"
# → MCP tool: detect_drift(from, to)
# "What's the commit history for this function?"
# → MCP tool: symbol_history(node_id)
5 temporal MCP tools give your assistant full time-travel capability across the codebase, including graph snapshots, stale file detection, and architectural drift analysis.
Your assistant picks up where it left off. Decisions, patterns, and insights persist across sessions with 9-component hybrid scoring:
Weights are configurable via codemem config set scoring.<key> <value>.
Codemem parses OpenAPI/Swagger specs, AsyncAPI specs, and detects event-driven patterns (Kafka, RabbitMQ, Redis, SQS, SNS, NATS) to build cross-service edges:
HttpCalls -- REST calls between servicesPublishesTo -- Event publish relationshipsSubscribesTo -- Event subscribe relationshipsSession-scoped memories and stale enrichments auto-expire. Set TTL on any memory:
{
"name": "store_memory",
"arguments": {
"content": "Temporary note: API key rotates Friday",
"ttl_hours": 72
}
}
Configure defaults in ~/.codemem/config.toml:
[memory]
default_session_ttl_hours = 168 # 7 days for session memories
expire_enrichments_on_reindex = true # Auto-expire stale analysis
Embedding providers -- run fully offline or use any API:
# Local (default, no API key needed)
export CODEMEM_EMBED_PROVIDER=candle
# Ollama (local server)
export CODEMEM_EMBED_PROVIDER=ollama
# OpenAI-compatible (Voyage AI, Together, Azure, etc.)
export CODEMEM_EMBED_PROVIDER=openai
export CODEMEM_EMBED_URL=https://api.voyageai.com/v1
export CODEMEM_EMBED_MODEL=voyage-3
export CODEMEM_EMBED_API_KEY=pa-...
# Google Gemini
export CODEMEM_EMBED_PROVIDER=gemini
export CODEMEM_EMBED_API_KEY=AIza...
Running with Ollama (e.g. nomic-embed-text or mxbai-embed-large) is significantly faster than the built-in Candle model, while still keeping everything local.
Configurable model, precision, and batch size:
[embedding]
provider = "candle"
model = "BAAI/bge-base-en-v1.5" # Any HuggingFace BERT model
dtype = "f16" # f32, f16, bf16 — half precision halves memory
batch_size = 16 # Tune for GPU memory / throughput
dimensions = 768 # Auto-detected for Candle
cache_capacity = 10000 # LRU embedding cache
Storage backends -- currently SQLite (local), with trait-object abstractions ready for Postgres+pgvector and remote graph backends:
[storage]
backend = "sqlite" # or "postgres" (future)
[vector]
backend = "hnsw" # or "pgvector", "qdrant" (future)
[graph]
backend = "inmemory" # or "neo4j", "postgres" (future)
valid_from/valid_to timestamps on all nodes. 5 temporal query tools: what_changed, graph_at_time, find_stale_files, detect_drift, symbol_historycodemem review) and MCP tool (review_diff)repo and git_ref for team-ready filteringcodemem_status tool~/.codemem/config.toml.unwrap() in production code, safe concurrency, versioned schema migrationsAlthough codemem is designed for code exploration memory (not generic conversational recall), it scores competitively on standard memory benchmarks:
Both benchmarks use stricter conditions than published baselines: recall limit of 10 (vs 50-100), no evidence oracle, no embedding fallback. Both were run with OpenAI text-embedding-3-small. With the built-in local BERT model (BAAI/bge-base-en-v1.5), LoCoMo scores 89.58% -- a ~2% gap that graph expansion closes entirely (91.49% for both models in codemem-graph mode). Higher scores are achievable with better embedding models without any architectural changes.
See bench/locomo/ and bench/longmemeval/ for methodology, reproduction steps, and detailed breakdowns.
graph LR
A[AI Assistant] -->|SessionStart hook| B[codemem mcp context]
A -->|PostToolUse hooks| C[codemem mcp ingest]
A -->|Stop hook| E[codemem mcp summarize]
A -->|MCP tools| D[codemem mcp serve]
B -->|Inject context| A
C --> F[Storage + Vector + Graph]
D --> F
F -->|Recall| A
32 tools organized by category. See MCP Tools Reference for full API documentation.
codemem init # Initialize project (model + hooks + MCP)
codemem search # Search memories
codemem stats # Database statistics
codemem ui # Open control plane UI (REST API + embedded React frontend)
codemem analyze # Full pipeline: index + SCIP + enrich + PageRank + clusters
codemem review # Diff-aware blast radius analysis (reads diff from stdin)
codemem consolidate # Run consolidation cycles
codemem export/import # Backup and restore (JSONL, JSON, CSV, Markdown)
codemem sessions # Session management (list, start, end)
codemem doctor # Health checks on installation
codemem config # Get/set configuration values
codemem migrate # Run pending schema migrations
codemem mcp serve # Start MCP server (JSON-RPC stdio, or --http for HTTP)
codemem mcp ingest # Process hook payload from stdin
codemem mcp context # SessionStart hook (+ 7 more lifecycle hooks)
See CLI Reference for full usage.
Optionally compress raw tool observations via LLM before storage:
export CODEMEM_COMPRESS_PROVIDER=ollama # or openai, anthropic
Scoring weights, vector/graph tuning, embedding provider, memory expiration, and storage settings persist in ~/.codemem/config.toml. Partial configs merge with defaults.
git clone https://github.com/cogniplex/codemem.git
cd codemem
cargo build --release # Optimized binary at target/release/codemem
cargo test --workspace # Run all tests
cargo bench # Criterion benchmarks
6-crate Cargo workspace. See CONTRIBUTING.md for development guidelines.
Codemem builds on ideas from several research papers, blog posts, and open-source projects.
See docs/comparison.md for detailed feature comparisons.
A standalone Rust memory engine for AI coding assistants. Single binary, zero runtime deps. Graph-vector hybrid with MCP tools.
工具
暂无工具列表。远程服务器在首次健康检查后会获得工具列表。
常见问题
在本页复制适用于 Cursor、Claude Desktop、Claude Code 或 VS Code 的 stdio 配置。它使用发布者的安装方式,而不是 PlugMCP 代理。
此记录未列出必需的环境变量。
Codemem 通过 stdio 在本地运行。
上次检查时间:2026-10-28。 A standalone Rust memory engine for AI coding assistants. Single binary, zero runtime deps. Graph-vector hybrid with MCP tools.