Krusch Context MCP
Local MCP server: five tools to store, retrieve, and retire project decisions. SQLite by default.
๐ Read the Systems Deep Dive: Check out the published architecture essay Beyond Flat Vector RAG: What Makes krusch-context-mcp Special on krusch.dev, or the local companion guide in
docs/WHAT_MAKES_IT_SPECIAL.md.
Krusch Context MCP gives AI coding agents (Cursor, Claude Code, Windsurf, Antigravity) persistent working memory across sessions. It captures architectural decisions, invariants, lessons, and bug diagnoses, warns on near-duplicate memories, maintains temporal lineage when facts are superseded or invalidated, and audits diffs against active constraints.
๐ซ What This Is Not
- Not a codebase AST or Git indexer: Code symbol search, call graphs, and Git DAG traversal belong in
krusch-gitor your IDE's native search. - Not a 61-tool cafeteria: Collapsed to strictly 5 canonical verbs (~350 prompt tokens) for boring reliability.
- Not a cloud SaaS platform: Runs 100% locally on your machine with zero external cloud dependencies.
- Not a monolithic domain suite: Legal compliance (
krusch-law), document ingestion (krusch-nexus), and contract graphs (krusch-biz) live in separate companion repositories.
โก 30-Second Quickstart
Requires Node.js >= 22.0.0. Run once inside your project repository:
npx krusch-context-mcp init
This command will:
- Validate Node >= 22.0.0 and initialize
.agent/context.dbvianode:sqlite. - Clear stale MCP tool schemas from local IDE caches.
- Create your project
.envwith sensible defaults. - Seed initial project context and run a diagnostic health check.
- Print copy-paste JSON configurations for Cursor, Claude Code, and Claude Desktop.
๐ ๏ธ The 5-Verb Agent Loop
Krusch Context MCP exposes strictly 5 canonical verbs designed to fit into standard coding workflows:
๐ค Recommended Agent Protocol
Coding agents should interact with memory at specific lifecycle boundaries:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 1. SESSION START โ
โ Agent calls retrieve(query: '*', include_state: true) โ
โ -> Obtains active invariants, recent decisions, blockers โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 2. DURING WORK โ
โ Agent calls remember(content: '...', category: '...') โ
โ -> If near-duplicate returned, agent calls revise(...) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 3. PRE-COMMIT / PRE-EDIT โ
โ Agent calls nudge(trigger: 'pre_commit') โ
โ -> Audits code against active invariants (max 3 findings)โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ก๏ธ Safe Memory Writes: Closed Taxonomy & Deduplication
To prevent memory hallucination and database pollution:
- Closed Taxonomy: Every write must use one of 5 categories:
decision: Architectural choices, design directions, trade-offs.invariant: Non-negotiable rules (e.g., "Use node:sqlite, zero native compiles").bug: Solved defects, regressions, and root-cause analyses.lesson: Tactical insights and framework discoveries.blocker: Active dependencies or external obstacles.
- Near-Duplicate Detection: If a proposed memory matches an existing active record ($\ge 0.85$ cosine similarity), the memory is saved with a warning proposing
revise(action: 'supersede', target_id: ...). This protects contrasting rules (e.g., "Allow CORS" vs "Do not allow CORS") while flagging twin facts. - Compulsory Invalidation Reasons: Calling
revise(action: 'invalidate')strictly requires a non-emptyreason. - Focused Audits:
nudgecaps findings at 3 with concrete evidence, rejectingevery_turntriggers to eliminate auditor nagware. - Span-Grounded Provenance & Drift Self-Healing: Passing
provenance: { file, locator, quoted_sentence }toremembercomputes a normalized SHA-256anchor_hashand line range (start_line..end_line). On subsequentretrieve(include_state: true)calls, the engine verifies the span on diskโautomatically healing line numbers when code shifts above it, or flagging[DRIFTED]when the underlying code changes.
๐ง Embedding Reality & Offline Mode
- Zero-GPU Default: If neither Ollama nor an API key is present, the engine runs 100% offline using deterministic keyword extraction, recency scoring, and heuristic tag indexing.
- Local Ollama (Optional): Set
OLLAMA_URL="http://127.0.0.1:11434"withEMBED_MODEL="snowflake-arctic-embed2"(8,192-token context,1024dims, ~664 MBVRAM, asymmetricquery:retrieval via/api/embed; also supportsqwen3-embeddingMRL1024d,nomic-embed-text, and legacybge-large). - Remote Cloud (Optional): Set
OPENROUTER_API_KEY="sk-..."withEMBED_MODEL="baai/bge-large-en-v1.5"(or any1024-dim OpenRouter embedding model) for zero-local-VRAM embeddings.
๐ When Do You Need PostgreSQL?
- Use SQLite (Default): Perfect for single developers, local IDE sessions, and projects with thousands of decisionsโfeaturing compact
Float32Arraybinary vector blobs (4 KB/row) and an external-content Porter-stemmedFTS5lexical index. Zero Docker, zero setup. - Use PostgreSQL (
STORAGE_MODE=postgres): Required only when scaling to multi-agent swarms across different machines needing centralized persistence and server-side pgvector HNSW indexing.
๐ Migration from v1.6 / v1.7
- Tool Aliases: Legacy tool names (
add_memory,search_memory,compile_state,supersede_memory,invalidate_memory,proactive_nudge) are automatically aliased to the 5 verbs with a deprecation notice. - Database Path: v1.7 used
.agent/memory.db. v1.8+ uses.agent/context.db. Runnpx krusch-context-mcp initto migrate. - See docs/MIGRATION.md for the complete mapping table.
๐งฉ Sibling Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ AI Coding Agent (Cursor / Claude) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโ
โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ krusch-context-mcp (v2.0) โ โ krusch-git (External) โ
โ Project Memory & Steering โ โ Codebase RAG & AST Search โ
โ (5 Canonical Verbs) โ โ (7 Specialized Tools) โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ .agent/context.db โ
โ (node:sqlite, Node โฅ22) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Other specialized tools (krusch-nexus, krusch-law, krusch-biz) run as independent MCP servers in their own repositories.
๐ป IDE Configuration
Cursor (.cursor/mcp.json)
{
"mcpServers": {
"krusch-context": {
"command": "npx",
"args": ["-y", "krusch-context-mcp"]
}
}
}
Claude Code
claude mcp add krusch-context -- npx -y krusch-context-mcp
Claude Desktop (claude_desktop_config.json)
{
"mcpServers": {
"krusch-context": {
"command": "npx",
"args": ["-y", "krusch-context-mcp"]
}
}
}
๐ Documentation & Specifications
- Canonical Tool Reference: Generated directly from live schemas (
npm run docs:generate). - Architecture & Failure Modes: 2-page specification covering schemas, indexes, and
v2.0.0multi-scale retrieval invariants. - Setup & Operations Guide: Zero-Docker setup and optional configurations.
- Migration Guide: Step-by-step v1.5 โ v1.6 โ v1.7 โ v1.8 โ v1.9.0 โ v2.0.0 mapping.
- Episodic Memory Guide: Deep dive into the closed taxonomy and lifecycle.
- Changelog: Version release notes.
- Official ICLR 2026 BEAM Empirical Report: Closed-system full-suite evaluation across all
100conversations (~178.34Mtokens) and2,000/2,000questions (100K,500K,1M,10Msplits) on 96 GB Blackwell G4 (snowflake-arctic-embed28K ctx on SQLite:v2.0.0reaches92.58%Hybrid 8K at100K,42.23%R@10at1M, and55.54%Hybrid 8K [93.00%IE] +48.18%/58.71%E2E QA at10M, beating cloudpast.devon Contradiction Resolution across all 4 splits and on10MMulti-Session Reasoning across both Referees [29.54%/38.33%vs.28.17%]) with5/5zero-leakage verification. - Evaluation Baseline Notes: Preliminary benchmark fixtures and token-budget metrics.
๐งช Testing
# Run full unit & contract test suite (100% SQLite, zero Docker)
npm test
# Check storage and memory health
npm run health
License
MIT ยฉ kruschdev