crag-anchor-mcp
Verified-memory engine that decomposes AI agent memories into atomic claims with executable falsifiers and continuously re-verifies them against reality, returning facts with freshness verdicts via 30 MCP tools.
README
crag Anchor
Unit tests for memory. The verified-memory engine for crag: every memory an AI agent saves is decomposed into atomic claims, each claim gets an executable falsifier, and a grounding loop re-verifies them against reality — so recall returns verified facts, not stale notes.
What it is
AI coding agents forget everything between sessions — and worse, when they do have memory, that memory silently rots: ports change, files move, decisions get reversed, and the agent keeps recalling the stale version with full confidence.
crag Anchor treats memory the way engineers treat code: untested memory is broken memory.
- Save — insights captured from agent sessions pass a write-path governance gate (schema checks, secret scan, dedup, lifecycle resolution) before they enter the corpus.
- Decompose — each insight is broken into atomic claims (P1–P5: existence, behavior, causal, spec, meta), and each claim gets an executable predicate — a cheap, read-only check that can prove it wrong.
- Ground — a background worker pool re-runs falsifiers (recall-triggered for hot claims, sweep-based for cold ones). Trust is how recently a claim was re-grounded against reality, not a number that only rises.
- Recall — hybrid semantic + full-text search (embeddings + BM25 +
confidence), with a per-hit liveness verdict (
fresh/aging/unverified/revalidating/stale) so the agent knows what to discount. - Govern — contradiction detection, arena adjudication, supersede chains, confidence lifecycle (verify/decay/promote), and a tiered disposition engine (T0 auto / T1 agent / T2 human) for anything an agent proposes to persist.
Architecture at a glance
Claude Code / Cursor session
│ (stdio)
▼
crag-anchor-mcp ──── 30 MCP tools, thin HTTP client, no local state
│ (HTTP, localhost)
▼
crag-anchor daemon ── FastAPI on 127.0.0.1:8786
│ ├─ embedding model (all-MiniLM-L6-v2, in-RAM)
│ ├─ claim layer (decompose → classify → author falsifiers)
│ ├─ grounding workers (v2 queue + v3 LLM adjudication)
│ ├─ disposition engine (T0/T1/T2 staging triage)
│ └─ capture pipeline (transcript tailer → extractor → emit)
▼
SQLite (WAL) ──────── engine.db: insights, principles, claims, falsifiers,
entity graph, grounding history, token ledger
See docs/architecture.md for the honest deep-dive.
The loop
One closed loop turns raw session failures into compiled governance:
capture → disposition (T0 auto / T1 agent / T2 human) → claims → grounding
→ principles → crag distill → .crag/governance.gen.md → crag compile → 23 targets
Trust score is the verified fraction of active claims — only principles whose claims roll up fresh are eligible to compile into governance, so the rules an agent obeys are derived from verified reality, not vibes.
Read-model contract
The daemon exposes ONE read-model; every surface (CLI, console, cloud, ops) renders these same aggregates. No surface owns logic.
| Endpoint | Returns |
|---|---|
GET /overview |
Trust hero: trust score, corpus counts, today's captured/verified/promoted |
GET /inbox |
Items that need a human — TRUE-T2 dispositions only |
GET /rules |
Memory-become-law: active principles with claim health |
GET /console/modules |
Data-driven console nav manifest (the nav IS data) |
Ops-only aggregates (GET /infra/stack, /infra/costs, /infra/sessions) are
served exclusively by the private operator instance, appended via the module
seam — never present in this open-source engine.
Surfaces
The engine is headless; surfaces render the read-model.
- Embedded console — ONE app, data-driven nav from
/console/modules. A module seam lets an operator instance append itsinframodule without a fork. Embeds via a contract (?embed=1+postMessage+frame-ancestorsfrom env). (Shipped, live 2026-07-18.) - crag CLI cockpit —
crag status/crag inbox/crag why <id>read the aggregates;crag sync --memorypushes an overview+rules snapshot to app.crag.sh. (Onfeat/memory-seam; ships in the next@whitehatd/cragrelease.) - Cloud — app.crag.sh stores pushed snapshots and renders a "Verified Memory" card. (Deployed.)
Roadmap (honest tense)
Shipped above is live today. In flight and planned:
- P0 — session lifecycle (in progress):
session_start/session_endMCP methods + per-harnesscommandhooks (invisible capture/sync, not skills the agent must remember). - Console v3 (in progress): five decision-surfaces (Memory · Needs You · Browser · Rules · Systems) on the live aggregates, behind a Playwright gate, flipped in via the manifest once they pass.
- P0.5 — BYO-key gateway (planned): bring ANY provider's key — paste-a-key → OS keychain → one provider-neutral gateway with per-role model aliases; spend caps enforced outside agent code. No subscription login (banned by providers in 2026).
- P1 — GitHub App (planned): quiet, evidence-linked PR receipts.
Quickstart
git clone <repo> crag-anchor && cd crag-anchor
python3 -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e '.[embeddings]'
crag-anchor # start the daemon (first boot downloads the ~90MB embedding model)
curl -sf http://127.0.0.1:8786/health
# register the MCP server with Claude Code:
claude mcp add --scope user crag-anchor crag-anchor-mcp
Docker, systemd, and launchd paths are documented in
packaging/README.md. Zero-config defaults are
repo-relative (db/engine.db, logs/, bind 127.0.0.1:8786); everything is
overridable via CRAG_ANCHOR_* env vars or db/stack.toml.
Relation to crag
crag (npm i -g @whitehatd/crag) is the deterministic
governance compiler: one governance.md source of truth, compiled into
every agent format (CLAUDE.md, .cursorrules, AGENTS.md, hooks). crag Anchor is
the memory + verification engine underneath it: verified insights distill
into principles, and principles whose claims roll up fresh can compile back
into governance rules (crag distill). Compiler + engine, one product: rules
that are derived from verified reality, not vibes.
MCP surface
30 tools — recall (recall, recall_principle, recall_by_entity), knowledge
capture (save_insight, suggest_tags), lifecycle (get, verify, update,
supersede, promote_insight), governance queues (audit, arena,
clear_suspect, grounding), disposition (disposition_list,
disposition_resolve, staging_triage), session state (session_diary,
project_context, events, brief), telemetry (recall_stats,
recent_insights, cost_report, add_token_record, health_check),
governance export (principles_export), and introspection (engine_guide,
graph). Full table in
packages/mcp-spec/README.md.
Development
pip install -e '.[all]'
ruff check . # lint
python apps/daemon/tests/test_engine_paths.py # test suites are standalone scripts
python db/tests/test_write_gate.py # (each exits 0 on pass, 1 on fail)
See CONTRIBUTING.md.
License
Apache-2.0 — see LICENSE and NOTICE. Every line of source in this repository is Apache-2.0 — no carve-outs, no dual licensing, no contributor surprises. Commercial capabilities (hosted console, team memory server, SSO/RBAC, audit export) are delivered as separate distributions built on this engine — see crag.sh.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。