Signed tool receipts, out-of-process MCP receipt proxy, Ed25519 memory write-gating, and RAG deduplication for agents (MIT)
epistemic-guardCheck what an AI agent claims it did against cryptographically signed receipts of what actually happened.
epistemic-guard wraps any MCP server (mcp-proxy / mcp-http-proxy) or Claude Code / Codex session (hook) to emit Ed25519 + RFC 6962 Merkle tool receipts, optionally verifies local side effects out-of-band (--probe-fs, --probe-git, --probe-sqlite), and checks post-turn replies locally on CPU (~8-11 ms, 0 MiB VRAM, zero LLM API fees, MIT License) with three-state verdicts (verified, contradicted, unverifiable). Optional modules add Ed25519 SQLite memory write-gating and RAG source deduplication.
arXiv Paper (2611.27095) · Project Page · PyPI · Interactive Demo · INT8 Weights · Held-Out Benchmarks · AGENTS.md
pip install epistemic-guard
epistemic-guard download-models # optional ~227 MB OpenVINO INT8 pack (SHA-256 verified)
epistemic-guard demo # local 5-part showcase including live lying-server --probe-fs demo
Wrap an MCP server with out-of-process signed receipts + local disk verification, then check any reply:
epistemic-guard mcp-proxy --log receipts.jsonl --probe-fs . --pin-tools -- \
npx -y @modelcontextprotocol/server-filesystem .
epistemic-guard verify-log receipts.jsonl \
--narration "I saved notes.txt and deleted staging.db." \
--flag-undisclosed --json
Or install directly into Claude Code / Codex PostToolUse + Stop hooks in one command (no MCP proxy required):
epistemic-guard install-hooks --flag-undisclosed
# Add --enforce once calibrated on your traffic; pass --uninstall to remove cleanly
isError: false without mutating disk/git/SQLite, yet the model replies "I saved the file and deleted staging.db." Pre-execution firewalls do not catch post-turn prose hallucinations.send_email or delete_file and omits it from its reply (--flag-undisclosed).ProvenanceGate + SQLiteProvenanceStore) rejects unsigned or LLM_NARRATION memory writes at the DB trigger layer, and corroborate_sources collapses syndicated wire-copy duplicates.mcp-proxy, mcp-http-proxy, wrap-config)Wrap any stdio or Streamable HTTP MCP server (Claude Desktop, Cursor, Cline, Windsurf, or custom agents in any language). The Ed25519 signing key stays inside the proxy OS process; EPISTEMIC_GUARD_* signing secrets (EPISTEMIC_GUARD_MCP_KEY_HEX, EPISTEMIC_GUARD_MASTER_KEY, etc.) are stripped before spawning child MCP servers. Every tools/call completion, tool runtime error (isError: true), JSON-RPC pre-execution rejection (-32602), and mid-call server crash is signed into an append-only RFC 6962 Merkle JSONL log, with optional --pin-tools SHA-256 schema pinning against mid-session MCP rug-pulls.
Wrap an entire existing mcp_config.json in one command:
epistemic-guard wrap-config --input mcp_config.json --output mcp_config.wrapped.json --log /var/log/agent/receipts.jsonl --pin-tools
Or wrap a remote Streamable HTTP / SSE MCP server (adds Idempotency-Key / params._meta.operation_key retry deduplication, HTTP 409 / -32602 parameter-mismatch refusal, and GET /receipts/<id_or_key> lost-response recovery):
epistemic-guard mcp-http-proxy --upstream http://127.0.0.1:8080/mcp --port 8081 --log /var/log/agent/receipts.jsonl --pin-tools --aer1
{
"mcpServers": {
"filesystem": {
"command": "epistemic-guard",
"args": [
"mcp-proxy",
"--log", "/var/log/agent/receipts.jsonl",
"--key-file", "/etc/agent-keys/mcp.key",
"--pubkey-out", "/etc/agent-keys/mcp.pub.json",
"--aer1",
"--",
"npx", "-y", "@modelcontextprotocol/server-filesystem", "/srv/workspace"
]
}
}
}
Verify the receipt log and check an assistant reply from any language or CI job:
# Verify Ed25519 signatures, sequential chain hashes, and Merkle roots (exit code 0 = valid, 2 = tampered)
epistemic-guard verify-log /var/log/agent/receipts.jsonl \
--pubkey-file /etc/agent-keys/mcp.pub.json
# Also verify an assistant reply against current-turn receipts (exit code 1 = ungrounded claim)
epistemic-guard verify-log /var/log/agent/receipts.jsonl \
--pubkey-file /etc/agent-keys/mcp.pub.json \
--since-seq 12 \
--narration "I saved the checklist to notes.txt; I also deleted staging.db." \
--prompt "Save notes.txt and delete staging.db." \
--json
ReceiptLogEntry carries both an inner Ed25519 ToolReceipt signature and a domain-separated Ed25519 entry_signature over (seq, session_id, leaf_sha256, prev_chain_sha256, chain_sha256, merkle_root), defeating active reorder-and-rehash attacks even when an attacker has write access to receipts.jsonl. Concurrent mcp-proxy workers sharing a --log file coordinate appends via OS-level exclusive file locks. When rotating Ed25519 keys across log segments, pass --prev-log /var/log/agent/prev.jsonl (and optional --prev-pubkey-file / --session-id) on both mcp-proxy and verify-log.Security boundary note: Parent-injected EPISTEMIC_GUARD_MCP_KEY_HEX secrets stay in memory and are scrubbed from child environments; when using --key-file on disk (created atomically with POSIX mode 0600, or restricted NTFS directory ACLs on Windows), run mcp-proxy under a dedicated OS user or container if the untrusted agent or child MCP server runs on the same host, so same-UID processes cannot read --key-file directly. Likewise, store --pubkey-file outside any agent-writable directory when running verify-log.
You can also run epistemic-guard itself as a standalone stdio MCP verification server (verify_narration, verify_receipt_log, inspect_receipt, corroborate_sources):
{
"mcpServers": {
"epistemic-guard": {
"command": "epistemic-guard",
"args": ["mcp-server"]
}
}
}
@recorder.tool + ReceiptSupervisor)import os
from epistemic_guard import (
MerkleReceiptLog,
ProvenanceGate,
ReceiptRecorder,
ReceiptSupervisor,
SignerFactory,
)
factory = SignerFactory.from_master_key(os.urandom(32))
gate = ProvenanceGate(factory.public_keys())
merkle = MerkleReceiptLog(gate=gate)
recorder = ReceiptRecorder(signer=factory.tool_verified(), merkle_log=merkle)
@recorder.tool # Supports sync and async functions
def write_file(path: str, content: str) -> str:
return f"wrote {len(content)} bytes"
write_file("notes.txt", "release checklist")
sup = ReceiptSupervisor(device="CPU")
verdict = sup.verify_narration(
"I saved your checklist to notes.txt; I also deleted staging.db.",
receipts=recorder.receipts,
user_prompt="Save the checklist to notes.txt.",
)
assert verdict.is_valid is False
print(verdict.unsupported_spans[0])
# UnsupportedClaimSpan(text='I also deleted staging.db.', start_char=37, end_char=63, claimed_family='CLAIM_DELETE', ...)