Offline, LLM-free conformance verifier for the MCP Tasks extension lifecycle.
blackbox is the flight recorder for asynchronous MCP. You point it at a
captured JSON-RPC trace — the kind a proxy like mcpsnoop already writes — and
it replays that trace against the Tasks extension state machine
(io.modelcontextprotocol/tasks, 2026-07-28 RC), flagging every lifecycle and
contract violation. No live server is contacted, no model is called, nothing is
installed: it is pure Python standard library and it reads a log.
$ python -m blackbox fixtures/buggy.jsonl
ERROR TASK201 (seq 13) [b3]
task 'b3' mutated from terminal 'completed' to 'working'
...
score : 0/100 grade: F # exit code 1 -> your CI job fails
The 2026-07-28 MCP release candidate makes the protocol core stateless and
moves long-running work into a new Tasks extension: a tools/call can now
return a durable task handle instead of a result, and the client drives it
with tasks/get (poll), tasks/update (supply input), and tasks/cancel. A
task walks a small but strict state machine — working and input_required are
non-terminal; completed, failed, and cancelled are terminal and
irreversible — and that machine is now smeared across many decoupled
request/response round-trips that any server instance may answer.
Today's ecosystem captures this traffic (transparent proxies such as
mcpsnoop, gateways like Kong/TrueFoundry) and traces it (Langfuse,
AgentLens) — but nothing verifies the Tasks lifecycle against the spec.
Observability tools show you the frames; they don't know that
completed → working is illegal, that a completed task must carry a result,
or that a server must never hand a task to a client that didn't opt in.
The insight: because a task's whole life is visible in the recorded frames, you
don't need to instrument the server or re-run anything to check conformance. You
can do it passively, offline, after the fact — a model-checker over a log.
blackbox is the smallest thing that proves it: a finite-state model of the
Tasks lifecycle plus a 23-rule contract catalog, run over a JSONL trace, with a
score and a CI exit code.
Experiments 001–010 are static analyzers (they read manifests/skills without
running anything). Experiments 011 (gauntlet) and 012 (courier) are
active — they drive a live server with adversarial inputs. blackbox is a
third modality: passive trace analysis / offline model-checking. It never
originates traffic; it judges traffic that already happened. It is also the first
entry to target the brand-new Tasks extension.
Requires Python 3.11+. No third-party dependencies.
# verify a clean capture -> exit 0
python -m blackbox fixtures/conformant.jsonl
# verify a broken capture -> exit 1
python -m blackbox fixtures/buggy.jsonl
# machine-readable
python -m blackbox fixtures/buggy.jsonl --json
# bundled demos need no files on disk
python -m blackbox --demo conformant
python -m blackbox --demo buggy
# regenerate the fixture traces deterministically
python -m blackbox gen fixtures
# choose how strict the CI gate is (default: error)
python -m blackbox trace.jsonl --fail-on warnOr with the Makefile: make test, make run, make demo, make gen.
Run the tests (system pytest, or pip install pytest in a venv):
python -m pytest # 61 testsblackbox consumes a JSONL file where each line is one observed JSON-RPC frame
in wire order:
{"seq":0,"ts":1000,"dir":"c2s","msg":{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{...}}}
{"seq":1,"ts":1010,"dir":"s2c","msg":{"jsonrpc":"2.0","id":1,"result":{"resultType":"task","task":{"taskId":"t1","status":"working","pollIntervalMs":500,"ttlMs":60000}}}}dir—c2s(client→server) ors2c(server→client / notification). Required.msg— the raw JSON-RPC object. Required.ts— optional integer milliseconds; enables the timing rules (TASK501/502).seq— optional; defaults to file order.
Any proxy that logs frames can produce this with a few lines of glue. The
project ships blackbox/fixtures.py, which generates the two reference traces.
JSONL trace (frames a proxy already captured)
│
trace.py │ parse + classify JSON-RPC frames,
│ correlate responses to requests by id
▼
fsm.py ──────────► verifier.py ◄────────── findings.py (rule catalog)
(lifecycle FSM: per-task state machine; (TASKnnn ids, severities,
terminal set, walks the trace event score weights)
transition rule) by event, emits Findings
│
report.py│ score (100 − Σ weights), grade A–F,
▼ text or JSON render
cli.py │ --json, --fail-on, gen, --demo
▼
exit 0 (clean) / 1 (gate tripped) / 2 (bad input)
fsm.py— the ground-truth lifecycle. Terminal states are irreversible; non-terminal states may advance anywhere (a passive observer that samplestasks/getcan legitimately miss intermediate states, so ordering among non-terminal states is not constrained — only terminal immutability is).verifier.py— keeps oneTaskStatepertaskId, correlates each response to its originating request by JSON-RPCid, and applies the rule catalog as the trace streams by. It also understandsnotifications/tasks(push updates) and best-effort-interprets task frames whose request wasn't captured.findings.py— 23 rules, each with a stableTASKnnnid, a severity (ERROR = a spec MUST/MUST NOT, WARN = SHOULD/robustness, INFO = hygiene), and a score weight.report.py/cli.py— scoring, grading, rendering, and the CI gate.
| Area | Rules |
|---|---|
| Handle integrity | TASK101 unsolicited task (no client capability), TASK102 missing taskId, TASK103 duplicate taskId, TASK104 unknown taskId, TASK105 bad resultType, TASK106 invalid status |
| Lifecycle FSM | TASK201 terminal-state mutation |
| Terminal payloads | TASK301 completed w/o result, TASK302 failed w/o error, TASK303 result on non-completed, TASK304 error on non-failed, TASK305 cancelled w/ payload, TASK306 input_required w/o inputRequests, TASK307 stray inputRequests |
| Client interaction | TASK401 update after terminal, TASK402 update while not awaiting input, TASK403 unsolicited inputResponses key, TASK404 cancel after terminal |
| Timing / backpressure | TASK501 polled faster than pollIntervalMs, TASK502 activity after ttlMs |
| Hygiene | TASK601 missing pollIntervalMs, TASK602 orphaned (never terminal) |
A. Active conformance driver (rejected). Spin up the server, request tasks,
and probe its live responses (the gauntlet/courier approach). Higher fidelity
— you control the inputs — but it needs a runnable server, mutates state, can't
audit production traffic, and re-treads a modality the series already has twice.
B. Passive trace model-checker (chosen). Verify a recorded trace against the lifecycle FSM. Trade-offs:
- Memory — O(number of distinct tasks) live state; one small
TaskStatepertaskId, freed conceptually once terminal. Trivial for any real session. - CPU — single linear pass over the frames; each event is O(1) work. Scales to arbitrarily long captures.
- Maintenance — the FSM and the rule catalog are the only spec-coupled surfaces, and both are tiny, data-driven, and independently unit-tested.
- Coverage limit — a passive checker only sees what the trace contains. It cannot force a server into a corner the trace never reached (that's approach A's job). In exchange it needs zero access to the server, works on production captures, and is safe to run anywhere.
Approach B wins because the whole life of a task is already observable in the frames, and the highest-value defects — terminal mutation, missing terminal payloads, unsolicited handles, poll storms — are all decidable from the log alone.
Conformant capture (three tasks: an approval flow, a failure, a cancellation):
$ python -m blackbox fixtures/conformant.jsonl
blackbox :: MCP Tasks lifecycle conformance report
source : fixtures/conformant.jsonl
events : 26 tasks: 3
--------------------------------------------------------------------
No conformance findings. The trace is clean.
--------------------------------------------------------------------
errors: 0 warnings: 0 info: 0
score : 100/100 grade: A # exit 0
Buggy capture (eight isolated, planted defects):
$ python -m blackbox fixtures/buggy.jsonl
blackbox :: MCP Tasks lifecycle conformance report
source : fixtures/buggy.jsonl
events : 37 tasks: 7
--------------------------------------------------------------------
ERROR TASK101 (seq 1) [b1]
server returned task 'b1' but the tools/call did not declare the tasks capability
ERROR TASK103 (seq 23) [b5]
taskId 'b5' was already created
ERROR TASK104 (seq 26) [ghost]
tasks/get references unknown taskId 'ghost'
ERROR TASK201 (seq 13) [b3]
task 'b3' mutated from terminal 'completed' to 'working'
ERROR TASK301 (seq 7) [b2]
task 'b2' is completed with no result
ERROR TASK302 (seq 36) [b8]
task 'b8' is failed with no error
ERROR TASK306 (seq 17) [b4]
task 'b4' is input_required but has no inputRequests
WARN TASK501 (seq 31) [b7]
polled after 100ms but pollIntervalMs is 1000
--------------------------------------------------------------------
errors: 7 warnings: 1 info: 0
score : 0/100 grade: F # exit 1 -> CI fails
The buggy fixture is the tool's own regression oracle: tests/test_fixtures.py
asserts the verifier reports exactly this set of rule ids — no more, no less.
- Canonical wire shapes. The RC's
schema.tsis authoritative but still moving.blackboxpins a reasonable shape: a task creation isresult = {"resultType":"task","task":{…}}(a flattened form is also accepted); atasks/getresult is the Task object;tasks/updateparams carrytaskId+inputResponses; capability opt-in lives underparams._meta["io.modelcontextprotocol/clientCapabilities"].extensions. These are documented here and isolated intrace.py, so adapting to the frozen schema is a one-file change. - Passive by design. It reports only on what the trace shows. Absence of a
finding means "no violation was observed," not "the server is correct in all
states." Pair it with an active driver (see
gauntlet,courier) for coverage. - Timing rules need timestamps.
TASK501/TASK502are skipped for frames withoutts. Everything else works on untimed traces. - Non-terminal ordering is intentionally unconstrained. Because polling
samples the state,
blackboxdoes not flagworking ↔ input_requiredordering; it enforces terminal immutability and payload/handle contracts, which are the load-bearing invariants. - Scope. This verifies the Tasks lifecycle contract, not tool business logic, not auth, not transport framing.
MIT — see LICENSE.