MCP Detect

MCP-DETECT captures Model Context Protocol tool traffic, applies a bounded set of structural and stateful detections, publishes adversarial evasions, and binds every measurement to exact reproducible evidence.

Scope

Research software, not autonomous enforcement or complete MCP protection. Every corpus and worked example is synthetic and self-authored.

Domain
Agentic AI security, detection research
Status
Open source under MIT
Role
Sole engineer, architecture through measurement
Stack
Python, MCP SDK, Wazuh, Docker, JSONL telemetry, Ollama lab
Evidence model
Frozen corpora, rule hashes, golden matches, and denied retests

At a glance

Claim

Makes selected MCP behaviors observable and produces reproducible evidence for five implemented abuse techniques.

Evidence

Ten rules plus two parent anchors, a 4,727-record benign corpus, five compiler gates, and a 12-class evasion corpus.

Boundary

All data is self-authored, 5 of roughly 85 SAF-MCP techniques are implemented, and there is no semantic detection backend.

On this page

MCP tool calls need inspectable evidence

MCP connects agents to filesystems, ticketing, memory stores, and internal services. A configuration review can list declared permissions, but it cannot show which tools were actually advertised, what arguments moved through them, whether metadata changed mid-session, or whether an undeclared server appeared in live traffic.

So the project asks a narrower set of questions. What evidence can be extracted from MCP traffic, which abuse techniques are detectable from that evidence, and which classes need controls outside telemetry?

Capture once, analyze through bounded paths

  1. Observe Transparent proxy Forwards MCP JSON-RPC bytes untouched and emits one JSONL event per message.
  2. Structure Telemetry schema Normalizes sessions, server commands, tools, arguments, and direction.
  3. Detect Rules and baseline Wazuh handles structural patterns. Python tracks stateful metadata drift.
  4. Measure Framework gates Runs fixtures, joins alerts to sessions, measures coverage, and records gaps.
  5. Reproduce Frozen evidence Checksums, rule hashes, golden matches, and source-level retests keep each claim inspectable.

Five techniques, each with a named evasion

9/12 documented evasion classes with a working detection; 3 are structurally undetectable

Covered Structurally undetectable blind spot

Tool poisoning

Flags hidden instructions embedded in advertised tool descriptions. It does not catch every semantic manipulation, and meaning-preserving rewrites can evade it.

Credential exfiltration

Correlates a sensitive-file read with secret-shaped content leaving in a later tool argument. Encoded or transformed secrets can evade plaintext matching.

Sensitive absolute paths

Matches a bounded list of high-risk absolute paths used with content-exposing file tools. Renamed tools, new paths, or indirection can evade.

Path traversal

Detects relative escape patterns in file-tool arguments. It complements, and does not replace, server-side path confinement.

Rug pull

Tracks hash-visible tool and server metadata drift across a stateful baseline. A legitimate upgrade looks identical to a malicious swap at this layer, and behavior-only changes are invisible.

Gates tied to real historical bugs

Each detection declares its backends, rules, session join, fixtures, status, and known gaps in a detection.yaml. The framework compiler checks schema, rule references, fixture references, session-key correctness, and false positives against a frozen benign corpus. Its tests reconstruct earlier failures so a new detection cannot silently reintroduce the same class of mistake.

10+2Rules and parent anchors
5Of ~85 SAF-MCP techniques
4,727Benign records, 541 sessions
0False positives on that corpus
12Documented evasion classes
5Write-side compiler gates

The five techniques are behaviors the rules implement. The 12 evasion classes are separate ways those detections can be bypassed. Nine leave a signal this sensor can test, and three are structurally invisible at this layer.

Measurement boundary

The corpora and worked examples are self-authored. Results are reproducible, but they are not evidence of performance against independent adversary traffic.

An AI Bill of Materials from observed traffic

The framework inventories observed MCP servers, tool names, version hashes, session counts, filesystem access, and network egress, then compares a declared known-good inventory against observations to surface shadow-server candidates. An unrecognized server is reported as unknown and routed to manual review, not assigned a guessed trust level.

What this cannot show

  • Coverage breadth. Five of roughly 85 SAF-MCP techniques are implemented.
  • No semantic backend. Prompt manipulation and meaning-preserving obfuscation are out of scope for the current detections.
  • Behavior-only compromise. A tool can return manipulated results without changing any visible metadata.
  • Encoded content. Base64 and similar transforms bypass plaintext secret matching.
  • Self-authored data. Independent or held-out traffic is the highest-value next validation step.
  • Offline analysis. The proxy captures traffic, but the workflow is not positioned as inline production enforcement.

Inside MCP Detect, from baseline to denied retest

I documented the project in three first-person articles. The series starts with model-selected benign traffic, pressure-tests the five detections, and ends at the authorization decision that telemetry could not prove.

  1. Part 1 Start by watching the agent behave 541 sessions, 1,011 model-selected calls, and the accepted zero-call git_show gap.
  2. Part 2 Build the detections, then break them Canonical results, benign regression, ten successful evasions, and the compiler gates those failures created.
  3. Part 3 Follow identity into the handler A synthetic cross-tenant defect, exact source fix, and denied authorization retest.

Inspect it yourself

The proxy, schema, complete synthetic corpora, rules, drift detector, compiler gates, coverage reports, and authorization reference are public under MIT.

Ten rules I wrote. Twelve attacks I built to break them.

12 evasion attempts / MCP Detect red team

Ten of the twelve still get through. E5, E8 and E11 have no fix I can write, and each says why in its own words on the bench below. E12 is closed by a deployed rule and E10 is a false-positive probe the rules correctly ignore.

  1. E1 Got in
  2. E2 Got in
  3. E3 Got in
  4. E4 Got in
  5. E5 No fix
  6. E6 Got in
  7. E7 Got in
  8. E8 No fix
  9. E9 Got in
  10. E10 Held
  11. E11 No fix
  12. E12 Held

Ten rules deployed on a byte-transparent MCP proxy, quiet across a 4,727-record benign corpus of 541 sessions.

  1. 100100
  2. 100101
  3. 100102
  4. 100103
  5. 100104
  6. 100105
  7. 100106
  8. 100107
  9. 100108
  10. 100109

Pick one and watch it get through

14 records / rules running in this page

Every rule below is the one deployed in MCP Detect, ported to run in this page. Pick an attack from the corpus, or edit the record and run something of your own against it.

Baseline

  • Unmodified credential read

Tool poisoning

  • E1 keyword avoiding
  • E2 no HTML comment
  • E3a zero-width insertion
  • E3b homoglyph
  • E4 distance bound

Credential exfiltration

  • E5 tool-name spoof
  • E6 untested key
  • E7 secret shape
  • E8 encoded payload
  • E9 read-path variant

Rug pull

  • E10 legitimate upgrade
  • E11 behavior only
  • E12 session-conditional

wazuh-logtest

telemetry.jsonl / Unmodified credential read

Rules evaluated
  • 100100 session_id, server_command matched, level 0, no alert
  • 100101 tool_arguments.path MATCH, level 12, T1552.001
  • 100102 raw.result.tools no match
  • 100103 tool_arguments.data no match
  • 100104 tool_arguments.payload no match
  • 100105 tool_arguments.content no match
  • 100106 tool_arguments.body no match
  • 100107 tool_arguments.message no match
  • 100108 tool_arguments.path no match
  • 100109 tool_arguments.path no match

Caught by 100101

rule 100101 level 12 T1552.001

No evasion applied. The attack as originally written.

This is the shape every class below is trying to get past.

Verdicts and mechanisms come from the project’s own Phase 5 red-team report. The reasoning behind them is in Catching Your Own Attack Only Proves the Plumbing Works, and the rules themselves are on the MCP Detect repository (opens in a new tab).