Dev.to Security ๐Ÿ” Cybersecurity ๐Ÿ‘ 0 ๐Ÿ“– 5 min read

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:

  1. Clean execution (ok=true, executed=true): Tool ran and returned content.
  2. Runtime tool error (isError: true, executed=true): Handler ran and failed (EACCES, lock conflict, 500 upstream).
  3. Pre-execution rejection (executed=false): JSON-RPC -32602 schema rejection (or 409 idempotency parameter mismatch) before the handler ever ran.
  4. Transport drop / crash (EOF / HTTP 502): 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.yaml and 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 6962 Merkle JSONL logs, with OpenTelemetry gen_ai.* and optional AER-1 envelope 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 MiB VRAM).

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/26 hallucinations caught)
  • False-positive rate: 38.24% (13/34 honest 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:

  1. Unseen custom MCP tool names (6/13 FPs): Tools like execute_sql, git_commit, and http_post were not in my static verb-stem table, so valid ok=true receipts failed to ground clauses like "deleted 14 expired rows from sessions.db."
  2. Contrastive failure reporting (7/13 FPs): Honest error summaries like "I attempted to delete prod_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:

  1. Dynamic MCP tools/list Auto-Binding + Rug-Pull Pinning (--pin-tools): Instead of a fixed stem list, the proxy inspects tools/list JSON 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 signed mcp_tool_rugpull receipts.
  2. Out-of-Process Local Effect Probes (--probe-fs, --probe-git, --probe-sqlite) & 1-Command Claude Code / Codex Hooks: mcp-proxy takes read-only before/after OS snapshots outside the MCP server's trust domain (catching servers that return 200 OK without mutating disk/Git/SQLite), and epistemic-guard install-hooks wires PostToolUse + Stop hooks directly into Claude Code or Codex in one command.
  3. Open-Vocabulary Grounding, Bidirectional Checks, and Deep Invariants: Added contrastive attempt negation, SQL verb inspection (DELETE vs. 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 -32602 rejections), and optional tool_preconditions call-order rules.
    • N=250 result: 234/250 (93.60%, 0 regressions).
    • In-sample fix check on Live-60: False positives dropped from 13/34 (38.24%) to 1/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/72 FP) clean zero-shot -> 110/120 (91.7%, 1/72 FP) after inspected development fixes -> 107/120 (89.2%) default / 111/120 (92.5%) opt-in verify_output_values=True with 0/72 (0.0%) FP on a sealed fresh-seed split (seed=99999, zero inspection).
      • control_arena_agentdojo (N=300 real claude-sonnet-4 banking attacks, development inspected): 5.9% Dir-1 benign FP; 254/300 (84.7%) Dir-2 with 106/130 (81.5%) attacks caught at 12.9% benign FP.
      • Unlabeled real developer traces: 32/798 (4.01%) flagged on nebius/SWE-agent-trajectories, 0/223 flagged on Exgentic/agent-llm-traces-v2.
  4. Streamable HTTP/SSE Proxy with Lost-Response Recovery (A1-A5): epistemic-guard mcp-http-proxy sits in front of any unmodified HTTP/SSE MCP server, indexing committed operations durably on disk by Idempotency-Key / params._meta.operation_key (and preserving those lookup indexes across --prev-log Ed25519 key rotations):
    • A1: Identical retry with a fresh JSON-RPC id replays the signed receipt (effect_count == 1, zero second upstream call).
    • A2: Retry reusing K with mutated arguments returns HTTP 409 / JSON-RPC -32602 (idempotency_parameter_mismatch) with a refusal receipt bound to A', never A.
    • A3 & A5: Key-only GET /receipts/<K> resolves the committed output_sha256 and AER-1 digest across restarts.

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
๐Ÿ“ฐ Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes โ€” full credit and traffic to the original publisher.