I fault-injected 60 live MCP tool failures: LLMs lied, my verifier hit a 38% false-positive wall, and here is what fixed both
(Paper now live on arXiv: arXiv:2611.27095. All code, fault-injection harnesses, SHA-256 osaudit provenance logs, and raw failure traces are open-source under MIT at the links below.) There is an active spec discussion
(Paper now live on arXiv: arXiv:2611.27095. All code, fault-injection harnesses, SHA-256 osaudit provenance logs, and raw failure traces are open-source under MIT at the links below.)
There is an active spec discussion in modelcontextprotocol/modelcontextprotocol#3394 examining what happens when a mutating MCP tools/call commits on the server, the network drops the response, and the agent retries.
That contract tests the wire half of the bug: does a retry trigger a duplicate external side effect (effect_count == 2)?
While building epistemic-guard (MIT, pip install epistemic-guard), I ran into the second half of the exact same failure loop: what the LLM tells the human user after an MCP call fails, gets rejected, or drops on the wire. When I tested my own verifier honestly against live faults, I promptly broke its precision.
Here are the raw numbers, including the ugly ones.
1. The Wire Gap vs. The Narration Gap
MCP standardizes how an agent invokes tools over stdio or Streamable HTTP/SSE. It does not bind what the model says afterward to what actually happened on the wire.
In real tool loops, four distinct wire states occur on tools/call:
-
Clean execution (
ok=true, executed=true): Tool ran and returned content. -
Runtime tool error (
isError: true, executed=true): Handler ran and failed (EACCES, lock conflict,500upstream). -
Pre-execution rejection (
executed=false): JSON-RPC-32602schema rejection (or409idempotency parameter mismatch) before the handler ever ran. -
Transport drop / crash (
EOF/ HTTP502): Process exited or connection dropped mid-call; outcome is indeterminate.
Even if your MCP server handles retries cleanly on the wire, an LLM receiving an error, timeout, or schema rejection routinely smooths over the failure in natural language:
"Done. I updated
prod_config.yamland sent the deployment notification."
And if your agent has episodic or RAG memory that indexes assistant turns, that unverified sentence gets retrieved in the next session as an established fact.
2. Static Benchmark (N=250) vs. Live MCP Fault Injection (Live-60)
To verify assistant prose without burning a second 12-24 GB GPU on an LLM-as-a-judge, epistemic-guard pairs:
- An out-of-process MCP receipt proxy (
HKDF-SHA256+Ed25519+RFC 6962Merkle JSONL logs, with OpenTelemetrygen_ai.*and optionalAER-1envelope export), and - An 82.7 MB OpenVINO INT8 10-class speech-act classifier + target-argument binder running in 17.9 ms median turn latency on CPU (
0 MiBVRAM).
On my frozen N=250 held-out action-receipt benchmark (v0.5.2, audited with ASSERT-KTH/osaudit and published in arXiv:2611.27095):
| Verifier | Hardware / VRAM |
N=250 Accuracy |
Recall | False-Positive Rate | Median Latency |
|---|---|---|---|---|---|
epistemic-guard (v0.5.2) |
CPU (0 MiB VRAM) |
93.20% (233/250) |
96.72% | 10.16% | 17.90 ms |
Qwen3-30B-A3B (Q4_K_M Judge) |
~18.5 GiB VRAM |
92.80% (232/250) |
95.90% | 10.16% | 141.80 ms |
Mistral-Nemo-12B (Q5_K_M) |
8.8 GiB VRAM |
86.80% (217/250) |
87.70% | 14.06% | 80.58 ms |
Phi-4-14B (Q6_K) |
12.2 GiB VRAM |
86.40% (216/250) |
100.0% | 26.56% | 76.24 ms |
| Receipt-Aware 7-Family Rule Baseline | CPU (0 MiB VRAM) |
74.80% (187/250) |
50.00% | 1.56% | < 0.1 ms |
DeBERTa-v3-xsmall (Off-the-shelf NLI) |
CPU (0 MiB VRAM) |
52.80% (132/250) |
24.59% | 20.31% | 22.40 ms |
Looked great on N=250. So I built a live 60-trace MCP fault-injection harness (Live-60: real stdio proxy runs injecting isError: true, -32602 invalid params, compound partial failures, and mid-call EOF crashes across two generator families) and ran v0.5.2 untuned.
Where v0.5.2 Broke (Live-60 Failing Marks)
-
Ungrounded claim recall:
96.15%(25/26hallucinations caught) -
False-positive rate:
38.24%(13/34honest turns wrongly blocked;76.67%overall accuracy)
(For comparison on the same 60 fault traces, Phi-4-14B hit a 61.76% FPR and Nemotron-30B hit 35.29% FPR; failed tool turns trip up LLM judges too.)
Inspecting all 13 false positives showed every single one came from two structural blind spots:
-
Unseen custom MCP tool names (
6/13FPs): Tools likeexecute_sql,git_commit, andhttp_postwere not in my static verb-stem table, so validok=truereceipts failed to ground clauses like "deleted 14 expired rows fromsessions.db." -
Contrastive failure reporting (
7/13FPs): Honest error summaries like "I attempted to deleteprod_ledger.db, but the operation failed due to a permission error" or "Please try the operation again" got split at the comma or misread as hanging promises.
I froze Live-60 (SHA-256 pinned on Hugging Face) and left the 38.24% FPR untouched in the v0.5.2 arXiv paper rather than tuning on the test set first.
3. Closing Both Gaps in v0.6.5 (Now Live on main & PyPI)
In v0.6.5, I addressed the root causes across both the MCP transport layer and the CPU verifier:
-
Dynamic MCP
tools/listAuto-Binding + Rug-Pull Pinning (--pin-tools): Instead of a fixed stem list, the proxy inspectstools/listJSON schemas to bind custom MCP tools automatically, and pins canonical SHA-256 digests of(name, description, inputSchema)so mid-session MCP tool-description mutations ("rug-pulls") are blocked and logged as signedmcp_tool_rugpullreceipts. -
Out-of-Process Local Effect Probes (
--probe-fs,--probe-git,--probe-sqlite) & 1-Command Claude Code / Codex Hooks:mcp-proxytakes read-only before/after OS snapshots outside the MCP server's trust domain (catching servers that return200 OKwithout mutating disk/Git/SQLite), andepistemic-guard install-hookswiresPostToolUse+Stophooks directly into Claude Code or Codex in one command. -
Open-Vocabulary Grounding, Bidirectional Checks, and Deep Invariants:
Added contrastive attempt negation, SQL verb inspection (
DELETEvs.SELECT), a lazy Stage-2 discourse NLI cascade, bidirectional undisclosed-mutation checks (--flag-undisclosed), three-state verdicts (verified/contradicted/unverifiable),RETRY_ARG_DRIFT(catching silent parameter/safety-flag changes after-32602rejections), and optionaltool_preconditionscall-order rules.-
N=250result:234/250(93.60%,0regressions). -
In-sample fix check on
Live-60: False positives dropped from13/34(38.24%) to1/34(2.94%,58/60[96.67%] accuracy). -
External & fresh-seed benchmarks (
1,441+third-party turns):-
B0yko/agent-claimcheck:90/120(75.0%,1/72FP) clean zero-shot ->110/120(91.7%,1/72FP) after inspected development fixes ->107/120(89.2%) default /111/120(92.5%) opt-inverify_output_values=Truewith0/72(0.0%) FP on a sealed fresh-seed split (seed=99999, zero inspection). -
control_arena_agentdojo(N=300realclaude-sonnet-4banking attacks, development inspected):5.9%Dir-1 benign FP;254/300(84.7%) Dir-2 with106/130(81.5%) attacks caught at12.9%benign FP. - Unlabeled real developer traces:
32/798(4.01%) flagged onnebius/SWE-agent-trajectories,0/223flagged onExgentic/agent-llm-traces-v2.
-
-
-
Streamable HTTP/SSE Proxy with Lost-Response Recovery (
A1-A5):epistemic-guard mcp-http-proxysits in front of any unmodified HTTP/SSE MCP server, indexing committed operations durably on disk byIdempotency-Key/params._meta.operation_key(and preserving those lookup indexes across--prev-logEd25519 key rotations):-
A1: Identical retry with a fresh JSON-RPC
idreplays the signed receipt (effect_count == 1, zero second upstream call). -
A2: Retry reusing
Kwith mutated arguments returnsHTTP 409/ JSON-RPC-32602(idempotency_parameter_mismatch) with a refusal receipt bound toA', neverA. -
A3 & A5: Key-only
GET /receipts/<K>resolves the committedoutput_sha256andAER-1digest across restarts.
-
A1: Identical retry with a fresh JSON-RPC
Try It Locally (0 MiB VRAM, MIT License)
pip install epistemic-guard
epistemic-guard download-models
# Wrap any local stdio MCP server with Ed25519 Merkle receipts + local disk probe:
epistemic-guard mcp-proxy --log receipts.jsonl --probe-fs . --pin-tools -- \
npx -y @modelcontextprotocol/server-filesystem .
# Verify the signed Merkle chain + check what the assistant claimed it did:
epistemic-guard verify-log receipts.jsonl \
--narration "I saved notes.txt and deleted production.db." --flag-undisclosed --json
# Or install directly into Claude Code / Codex hooks in one command:
epistemic-guard install-hooks --flag-undisclosed
-
arXiv Paper (
v0.5.2baseline): https://arxiv.org/abs/2611.27095 -
GitHub (MIT,
v0.6.5): https://github.com/AlienatedAliens/epistemic-guard - PyPI: https://pypi.org/project/epistemic-guard/
- Interactive Demo: https://huggingface.co/spaces/RollSolo/epistemic-guard
-
Benchmarks (
N=250,Live-60,AER-1): https://huggingface.co/datasets/RollSolo/epistemic-guard-benchmarks - OpenVINO INT8 Weights: https://huggingface.co/RollSolo/epistemic-guard-int8
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes โ full credit and traffic to the original publisher.