context-lattice

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.

Category
Visit Server

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 containing session_meta and response_item records;
  • 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_key values;
  • 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.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured