
Context Mem
io.github.JubaKitiashvili由 GitHub 帳號 JubaKitiashvili 發布v3.2.1更新於 Oct 24, 2026
Persistent memory for AI agents — 98%+ retrieval recall, 99% token savings, 44 tools
概覽
一個本機 MCP 伺服器,為 AI 助理提供持久且壓縮的專案記憶:儲存觀察記錄、建立可檢索的知識庫並隨時召回。
- 可以做什麼
- 儲存與召回觀察記錄,自動摘要、重要性評分、實體擷取與主題辨識,並提供混合關鍵字與向量檢索及以記憶庫為基礎的自然語言問答。管理知識圖譜與時間事實:儲存與搜尋知識、解決矛盾、遍歷實體關係、查詢某一時點的真實狀態。重建脈絡:沿證據鏈解釋決策、比較不同時間點的專案狀態、預測哪些記憶面臨壓縮風險,並產生 PR 說明、站立會議更新、ADR 或上手文件。協調工作階段與代理:喚醒脈絡、工作階段交接與還原、代理註冊、檔案佔用與廣播。
- 適用情境
- 適合長時間的程式開發工作,尤其是助理在工作階段之間反覆遺失脈絡,或工具輸出撐爆脈絡視窗的情況。也適合希望擁有本機、可檢查的記憶庫,以及可用 Obsidian 瀏覽或以 grep 搜尋的 markdown 知識庫的開發者。
- 執行需求
- 透過 npm 套件 context-mem 以 stdio 作為本機程序執行,需先安裝並執行其 init 指令寫入編輯器設定。需要 Node.js。未宣告 API 金鑰、雲端帳號或環境變數,核心功能可完全離線使用。選用的 LLM 重排需在設定中啟用並產生 API 費用。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Context Mem,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
[Context Mem — memory + context infrastructure for AI agents]
Context Mem
Memory + context infrastructure for AI agents. Remembers everything. Compresses everything. Fully local.
[npm version] [LongMemEval] [Token savings] [tools] [license]
The Problem
Two problems with today's AI tooling that no one has solved together in a single package.
Your AI forgets. Every new session starts from zero. The architecture decisions you settled on last Thursday, the bug you spent four hours tracing to a misconfigured environment variable, the preferences you stated three times — none of it carries forward. You spend the first ten minutes of every session re-explaining context that already existed. Multiply this by every developer on your team, every project, every day.
Your context explodes. Long coding sessions blow past the context window. A typical session with 50 tool outputs accumulates 365 KB of raw text — stack traces, test output, file reads, shell commands. Every token costs money or slows the model. Naive truncation drops the exact evidence the model needs. Keeping everything makes responses slower and inference cost climb fast.
These two problems compound each other. The solution to forgetting (keep everything) is the opposite of the solution to context explosion (discard everything). The result is a false tradeoff most tools force on you: either your AI forgets everything, or your costs balloon. context-mem solves both simultaneously by building an indexed, compressed, retrievable memory store rather than dumping raw history into the context window.
The Solution — one tool, two pillars
Pillar 1: Memory (LLM Wiki)
Every tool call is automatically ingested, summarized, and written into a navigable markdown vault — a living wiki your AI maintains about your project. Entities get their own pages with backlinks. Topics get synthesis pages. Sessions become browseable source documents. Decisions accumulate into a reconstructible trail.
The vault lives at .context-mem/vault/ and syncs continuously from the underlying SQLite store. Read it in Obsidian, grep it from the terminal, or query it through 45+ MCP tools using hybrid BM25 + vector + optional LLM judge search. The raw SQLite store is the authoritative record; the markdown vault is the derived, human-readable layer.
This is a reference implementation of Andrej Karpathy's LLM Wiki pattern — three layers (raw sources / wiki / schema), with automatic ingest from tool calls that no other system provides.
Pillar 2: Compression (14 summarizers)
Every observation passes through a content-aware summarizer before storage. A stack trace is not treated the same way as a JSON config file. Shell output from a build is compressed differently from TypeScript compiler errors. The system applies the right compression for the content type.
The result: a full coding session with 50 tool outputs goes from 365 KB to 3.2 KB — 99.1% token savings, verified. Compression is adaptive: recent high-importance observations stay verbatim; older low-importance ones compress progressively. Pinned entries never compress regardless of age.
One Command
init auto-detects your editor and writes the right config files:
No API keys. No cloud account. No data leaves your machine.
Dual-pillar in 60 seconds
[ placeholder: GIF or video — Claude Code session with split view showing Obsidian graph updating in real time alongside the context-mem dashboard token savings chart ]
Architecture (reference implementation of Karpathy's LLM Wiki pattern)
Three layers (per Karpathy):
- Raw sources — your tool call outputs, file reads, shell commands, observations. Written once, never modified. The permanent record.
- The wiki — LLM-maintained markdown vault (
.context-mem/vault/). Auto-synced from SQLite. Human-readable, Obsidian-compatible, grep-friendly. Entity pages, topic pages, session pages, knowledge pages, index, event log. - Schema —
docs/llm-wiki-schema.mdgoverns page structure, linking conventions, agent workflow recipes, and interop contract. Public spec — other tools can emit conforming wikis.
The distinction from most memory systems: context-mem is not replacing SQLite with markdown. SQLite is authoritative — it is where observations are stored, searched, and indexed. The vault is the browseable, linkable, diffable surface on top of it — the layer a human or LLM can navigate without a database client. If you delete the vault directory, you lose nothing that matters. If you edit a vault page manually, those edits are preserved and not overwritten on the next sync.
This is the Karpathy three-layer model applied to a running AI development environment: immutable inputs, a maintained synthesis layer, and a public schema that governs the synthesis. The vault can be used independently of the MCP tools — it is just a directory of markdown files. Open it in any editor. Put it in git. Diff it across commits. Use it as long-form context by copy-pasting pages into a new conversation. The MCP tools are the automated path; the markdown vault is the portable, durable, human-readable path.
Retrieval benchmarks (honest methodology)
All scores are session-level retrieval recall: did any correct evidence session appear in the top-k results? This is different from end-to-end QA accuracy (retrieve + generate + judge), which is harder and lower for every system. Both measurements are published here.
Pure local (zero API calls, fully free)
With optional LLM reranking (~$1 per 500 queries)
The LLM judge (Claude Haiku) scores the top-N BM25+vector candidates 0–10 and blends 50/50 with the retrieval score. Activates when ai_curation.enabled = true. Adds ~$0.002 per query at Haiku pricing.
Methodology notes:
- A "hit" is scored if any correct evidence session appears in top-k. Not end-to-end QA.
- LoCoMo benchmark appends dataset-provided metadata (session_summary, observation, event_summary) to session documents — the production system applies equivalent enrichment via summarizers and entity extraction.
- Synonym expansions: core query-builder includes general-vocabulary synonyms (movie → film, sibling → brother). Results without any synonym expansion are ~1-2% lower.
- All benchmark code is open and runnable:
npm run bench. Seebenchmarks/.
Full methodology: docs/benchmarks/methodology.md (published with v3.4).
Compression benchmarks (verified)
Per-summarizer breakdown:
Compression is lossless at the semantic level for high-importance observations (DECISION, MILESTONE, PROBLEM flags) — those stay verbatim regardless of age. Compression applies to routine tool output.
Core features
Memory
- LLM Wiki substrate — markdown vault at
.context-mem/vault/, auto-synced from SQLite. Entity pages, topic pages, session source pages, knowledge pages, index.md, log.md. Obsidian-compatible, grep-friendly. - 14 content-aware summarizers — JSON, shell, code, logs, errors, TS errors, tests, builds, git logs, HTML, markdown, CSV, binary, network. Each tuned for its content type.
- Adaptive 4-tier compression — verbatim (0–7 days) → light (7–30 days) → medium (30–90 days) → distilled (90 days+). Pinned entries stay verbatim forever.
- Knowledge graph — typed entity-relationship model: files, modules, patterns, decisions, bugs, people, libraries, services, APIs, configs. Traversable via
graph_query,graph_neighbors,add_relationship. - Temporal facts —
valid_from/valid_toon all knowledge entries. Supersession chains.temporal_queryanswers "what was true about X at time T?" - Decision trail reconstruction —
explain_decisionwalks the evidence chain backward: file reads → errors → searches → the decision. Full provenance. - Entity intelligence — auto-detect technologies, people, file paths, CamelCase identifiers, ALL_CAPS constants. 100+ canonical aliases (React.js → React, Node → Node.js, etc.).
- Session narratives — 4 ready-made templates: PR description, standup update, ADR, onboarding guide.
context-mem story --format pr. - Wake-up primer — token-budgeted context injection at session start. 4 layers: project profile (15%), critical knowledge (40%), recent decisions (30%), top entities (15%).
- Per-prompt injection — UserPromptSubmit hook auto-injects relevant memories on every message. Rate-limited, topic-deduplicated. Zero manual commands.
Compression
- 14 content-aware summarizers — not one-size-fits-all. A stack trace gets different treatment than a JSON response.
- Pinned verbatim preservation — decisions, milestones, and manually-pinned observations never compress.
- Priority-tiered truncation cascade — if the context budget is exceeded, lower-importance items are compressed first. High-importance items survive.
- Configurable token budget — three overflow strategies: compress oldest, compress lowest-importance, or hard truncate.
- 365 KB → 3.2 KB — verified on a typical 50-tool-output coding session.
Both
- Hybrid search — BM25 (8 strategies + synonym expansion) + vector (nomic-embed-text-v1.5, 768-dim) + trigram + Levenshtein run in parallel, fused via intent-adaptive weights with IDF-weighted content reranking. Optional LLM judge reranker.
- Temporal resolver — deterministic parsing for relative date queries ("3 days ago", "last Saturday", "last week"). Zero LLM cost. Returns absolute date range with confidence level.
- 45+ MCP tools — observe, search, recall, ask, timeline, knowledge graph, entity detection, temporal query, session handoff, multi-agent coordination, token budget, dashboard, diagnostics, and more.
- Fully local, zero cloud — SQLite on your machine. No telemetry. No API keys required for core functionality.
- 9-detector privacy engine — strips
<private>tags, applies custom regex redactions, detects API keys, tokens, passwords, PII patterns. Nothing sensitive leaves your machine. - Sub-millisecond operations — importance classification at 556K ops/s, entity extraction at 179K ops/s, BM25 search at 3.3K ops/s, all local.
How it compares
The memory space has multiple incumbents. The context-compression space has a few more. No other tool addresses both axes together.
Notes on this table: Retrieval recall figures for Mem0, Graphiti, Zep, and Letta are not published against the same benchmarks (LongMemEval, LoCoMo, MemBench, ConvoMem) at session-level retrieval recall using a methodology comparable to ours. If published numbers exist in their docs, they are for different datasets, different granularity (chunk-level vs. session-level), or with undisclosed infrastructure. Do not compare them directly. E2E QA numbers for context-mem will be published with v3.4. All other comparisons are based on public documentation as of April 2026.
The "token compression" row deserves a note: Mem0, Graphiti, and Zep are primarily retrieval systems — they do not claim to solve the context-window cost problem. Letta has partial compression via summarization. context-mem's 99.1% figure is measured on a real coding session (50 tool outputs, 365 KB → 3.2 KB). The measurement is reproducible: you can run it yourself against your own project by comparing context-mem stats --raw vs context-mem stats --compressed.
Real-world examples
Get started
1. Install
init creates the right MCP config for your editor. No IDE restart required for Claude Code. For Cursor, Windsurf, and VS Code, restart the IDE after init.
2. Configure MCP (manual option)
If you prefer to configure manually, add to your MCP config:
For Claude Code specifically, init also writes 8 hooks into .claude/settings.json that auto-inject relevant memories on every prompt submission — no manual observe calls needed during normal development.
3. Enable the LLM Wiki vault (v3.4+ opt-in)
Add to your context-mem config (.context-mem/config.json):
The vault directory will auto-populate on the next observation ingest. Open .context-mem/vault/ in Obsidian to browse the graph view of your project's knowledge.
The vault is opt-in in v3.4 and will be default-on in v4.0.
4. Dashboard
Opens a local web UI on http://localhost:3141 with 6 pages: Intelligence Overview, Knowledge Graph, Topics, Timeline, Entities, and Diagnostics.
5. Benchmarks (run them yourself)
All benchmark code is open. No hidden adapters that inflate numbers. See benchmarks/ and docs/benchmarks/methodology.md.
MCP tools reference (45+)
context-mem exposes its entire surface area as MCP tools — no proprietary SDK, no wrapper library, no lock-in. Any MCP-capable host (Claude Code, Cursor, Windsurf, VS Code, Cline, Roo Code, Aider, Continue, JetBrains AI, CrewAI, LangChain, AutoGen) can use these tools directly. There are no "premium" tools behind a paywall and no features that require a cloud subscription. Every capability listed in this README is available via the open MCP interface.
Core memory tools:
Knowledge graph tools:
Temporal and intelligence tools:
Session and agent tools:
System tools:
Diagnostic API
If you need to inspect what the system is doing:
Returns error log, pipeline stats, active session, storage health, search index state.
Multi-agent support
context-mem supports parallel AI agents working on the same project without collisions:
Shared memory prevents duplicate work. Claimed files prevent merge conflicts. Broadcast keeps all agents synchronized on discoveries.
Architecture reference: search pipeline
The retrieval stack runs 8 BM25 strategies in parallel, each with different weight and precision/recall tradeoff:
Plus temporal resolution (weight 1.6): relative date queries ("last Saturday") are resolved to absolute date ranges deterministically before search — zero LLM cost.
Vector search (nomic-embed-text-v1.5, 768-dim) runs in parallel with BM25 on the top-30 candidates, not in cascade. Results are fused via intent-adaptive weights (BM25: 0.45, trigram: 0.15, Levenshtein: 0.05, vector: 0.35) with IDF-weighted content reranking. Optional LLM judge blends 50/50 with retrieval score on the final top-N.
LLM Wiki schema
The vault follows a documented schema at docs/llm-wiki-schema.md. It specifies:
- Directory layout (
sources/,entities/,topics/,knowledge/) - Page types and frontmatter conventions
- Linking syntax (
[[entity-name]]resolves toentities/entity-name.md) - Operations: ingest / query / lint
- Agent workflow recipes for CLAUDE.md / AGENTS.md
- Interop contract — other tools can emit conforming wikis that context-mem can import
This is a public spec. Community RFCs at github.com/JubaKitiashvili/context-mem/discussions.
Performance characteristics
All core operations are synchronous and sub-millisecond. No LLM required for any default operation.
Vector embedding (nomic-embed-text-v1.5) adds ~5–15ms per query when vector search is enabled — still faster than any network call. The optional LLM judge adds one Haiku API call (~100ms) and is only invoked when ai_curation.enabled = true.
Changelog highlights
- v4.0.0 — Full LLM Wiki release. Synthesis pages, Obsidian plugin, 8 IDE integrations, Context Protocol RFC, compression polish. Target 2026-05-22.
- v3.4.0 — LLM Wiki Preview. Markdown vault layer, schema spec v1, E2E QA benchmark, issue #6 closed (benchmark methodology disclosure).
- v3.3.0 — Foundations. CI, error log, diagnostics. Silent patch.
- v3.2.0 — Hybrid parallel search. BM25 + vector in parallel, intent-adaptive fusion.
- v2.5.0 — Dashboard. Real-time web UI, knowledge graph visualization.
License: MIT
Built by Juba Kitiashvili.
Credit: Andrej Karpathy for the LLM Wiki framing (2026-04-04). Vannevar Bush for Memex (1945).
來源:README.md,提交 2a55af0
工具
0版本歷史
1- v3.2.1最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分