~/muadh/writing/mcp-behavioural-diff about writing

MCP Behavioural Diff

Differential runtime analysis for Model Context Protocol (MCP) servers.

Given two versions of an MCP server, it executes both under identical tool-call scenarios, captures their outbound HTTP / filesystem / process activity and tool results, learns which fields are nondeterministic from repeated runs, and reports behavioural changes with each outbound value traced to its observed source (a tool argument or an environment variable).

Scope of claims (read this first). Three separate things, kept separate:

  1. Behavioural-change detection: did on-the-wire / result behaviour change between versions? (this tool does this)
  2. Suspicious-change identification: does a change have a risk-relevant shape (new destination, unexplained value, a secret appearing in a field)? (partially)
  3. Maliciousness classification: is it actually an attack? (this tool does NOT do this.) A flagged change can be a legitimate release change; a human adjudicates.

It is not a malware detector and makes no such claim.

Why runtime diff (vs source/AI code review)

Postmark @activecampaign/postmark-mcp 1.0.0 → 2.1.1 is a near-total rewrite (1,539 lines of source diff, 4 → 24 tools, Postmark SDK → fetch). Its sendEmail outbound request is behaviourally identical: 0 field changes. Source review drowns in 1,539 lines; behavioural diff surfaces only what actually changed on the wire.

Install & run (isolated environment only, see docs/SAFETY.md)

RUNS=10 ./run.sh          # installs SDK + pinned servers, runs probe + evaluations

Single comparison:

npm install && node engine/mock.cjs > engine/.mockport &   # start mock
RUNS=10 node engine/cli.mjs <serverA/index.js> <serverB/index.js> scenarios/postmark.json

What a report contains

observed_source is an observed in→out relationship via unique canary markers, not full taint lineage. It cannot prove data flow through arbitrary transforms, subprocesses or native code.

Verified results (in reports/, reproducible via run.sh)

Network-active coverage (3 independent implementations)

Postmark (SDK https.request and fetch), Brave Search (fetch GET), @tokenizin/mcp-npx-fetch (fetch GET). See servers.manifest.json for pinned versions + sha512.

Layout

engine/   shim.cjs (capture+redirect)  runner.mjs (MCP driver)  mock.cjs  diff.mjs  cli.mjs  probe.mjs  canaries.json
scenarios/  tool-call scenarios (canary-tagged)
docs/     INSTRUMENTATION.md  SAFETY.md
servers.manifest.json   run.sh   reports/

Status / limitations

Node.js + stdio servers only. Positional request alignment (a new request shifts indices). strace/eBPF syscall backstop not yet implemented (planned). N=10 volatility learning is a small sample. See docs for the full list.

source, reports and docs: github.com/McBoomer/mcp-behavioural-diff (apache-2.0).