context-lattice
Enables MCP-capable clients to query coding-agent conversation exports and retrieve token-bounded evidence bundles with source provenance and hash verification, so LLMs can ground responses in verifiable history without replaying full transcripts.
README
Context Lattice
Context Lattice is a standalone, source-verifiable memory index for AI coding-agent conversation exports. Point it at JSON or JSONL produced by tools such as Codex, Cursor, Kiro, or your own agent, then retrieve a compact evidence bundle instead of replaying an entire history into the next context window.
Raw records remain immutable. Hierarchical summaries are lossy, disposable navigation indexes. Every result points back to the source file, JSON record, and SHA-256 hash.
Quick start
No API key or external database is required. Python 3.11+ is supported.
cd /path/to/context-lattice
python3 -m pip install -e .
context-lattice init --root ~/exports/coding-sessions/
context-lattice ingest ~/exports/coding-sessions/
context-lattice query "Why did we change the retry policy?"
context-lattice query "What is the latest payment reference?" --json --debug
context-lattice inspect
context-lattice verify
context-lattice doctor
By default the database is created at ~/.context-lattice/memory.db. Override it with
--db /path/to/memory.db. Ingestion accepts a single .json, a .jsonl, or a directory
tree containing both. init prints ready-to-paste MCP configuration using the same database
and source roots, avoiding CLI/server configuration drift.
Install as an MCP server
Context Lattice exposes memory_search, memory_get, memory_explain, memory_sync, and
memory_status over local stdio MCP. Configure the database and an explicit source
allowlist, then point any MCP-capable client at the installed executable:
{
"mcpServers": {
"context-lattice": {
"command": "context-lattice-mcp",
"env": {
"CONTEXT_LATTICE_DB": "/absolute/path/to/memory.db",
"CONTEXT_LATTICE_ALLOWED_ROOTS": "/absolute/path/to/agent/sessions"
}
}
}
}
Multiple allowed roots use the platform path separator (: on macOS/Linux, ; on
Windows). memory_sync is the only mutating MCP operation. Search evidence is explicitly
marked untrusted, bounded by a token budget, and resolvable to source hashes. See
docs/MCP.md.
Input adapters
--adapter auto examines record envelopes and currently recognizes:
codex: event JSONL containingsession_metaandresponse_itemrecords;cursor: exported conversations containing messages, bubbles or turns;kiro: role/content JSONL with a metadata header;claude: Claude Code project JSONL with nested message blocks;canonical: the stable Context Lattice v1 format;generic: common role/content, speaker/text and nested-message shapes.
Provider formats can change. The Codex, Cursor and Kiro adapters are intentionally tolerant
and fixture-tested, but the canonical schema is the guaranteed integration boundary:
schemas/conversation-v1.schema.json. See
examples/canonical.json for the smallest complete example.
{
"schema": "context-lattice/v1",
"conversation_id": "release-planning",
"messages": [
{
"role": "user",
"content": "The deployment region is ap-south-1.",
"timestamp": "2026-08-20T10:00:00Z",
"fact_key": "deployment-region",
"entities": ["ap-south-1"]
}
]
}
Records without recognizable conversational content are counted as skipped. Malformed or failed records are reported in the import result and stored in the import audit log. Re-importing the same file is idempotent.
Retrieval model
- immutable, append-only raw events in SQLite;
- original raw JSON plus file/record provenance and hashes;
- FTS5/BM25 for exact identifiers;
- an inverted sparse-postings index with an offline feature-hashing baseline;
- fixed-fanout chronological summary trees;
- reciprocal-rank fusion across lexical, semantic and hierarchical candidates;
- correction chains through optional
fact_keyvalues; - disagreement-triggered search expansion and confidence-based abstention;
- explicit evidence-token budgets and inspectable retrieval traces.
The indexer and retriever are deterministic and make no LLM calls. The bundled semantic model is feature hashing, so it is portable and exact-repeatable but weaker than a learned embedding model. An external LLM may consume the evidence; it is not trusted to maintain the memory index. The embedder boundary can be replaced without changing the evidence contract.
The chronological hierarchy is a segment-tree-like navigation index. It cannot replace
semantic or lexical lookup: trees prune time ranges, while FTS5 and sparse postings locate
terms and concepts. Query-time dot products are aggregated inside SQLite, and only a
bounded root set and beam descend the tree. See docs/ARCHITECTURE.md.
Test and evaluate
python3 -m unittest discover -s tests -v
python3 -m context_lattice.cli eval --output benchmark-results.json
python3 -m context_lattice.cli golden-eval --output golden-results.json
python3 -m context_lattice.cli demo \
"What is the current meeting room for team-3?"
The deterministic 50-question evaluation compares a recent-token window, rolling summary,
flat vector search and hierarchical hybrid retrieval. Its answer_accuracy is an evidence
sufficiency metric—not an LLM-judge score. See benchmark-results.json
and DESIGN.md.
The manually reviewed golden-v1 suite is the release gate for source recall, precision,
ranking, stale facts, unsupported results, citation integrity, and hierarchy branch recall.
It intentionally fails the command when thresholds regress. See
docs/GOLDEN_EVAL.md.
Production posture
The local-first core has atomic per-conversation index updates, WAL concurrency,
cross-process maintenance locking, immutable events, source verification, bounded inputs and
retrieval, nested-symlink-safe MCP allowlisting, schema compatibility checks, CI, and
deterministic release gates. context-lattice doctor checks database integrity, index
freshness, FTS5, permissions, SQLite, Python, and MCP. Provider formats remain unofficial and
can change; the canonical v1 schema is the stable integration boundary. Review
SECURITY.md before exposing anything beyond local stdio.
The concrete release checklist and current non-goals are in
docs/RELEASE_GATES.md.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。