feat(mcp): M2 dispatcher hardening — FALSIFY-MCP-005 + -007 gates#868
Merged
Conversation
Add two protocol-level invariants to the JSON-RPC dispatcher that must hold before method routing: - FALSIFY-MCP-005: requests with `jsonrpc != "2.0"` are rejected with `-32600 Invalid Request`. The check fires before method lookup so a malformed request to `initialize` / `tools/list` / `tools/call` cannot bypass version validation. - FALSIFY-MCP-007: `initialize.params.protocolVersion` mismatch returns `-32602 Invalid Params`. A missing field is permitted (some clients omit it on first handshake); only an actual mismatch is rejected. Positive case test guards against the guard accidentally tripping the happy path. 3 new integration tests in `tests/falsify_m1.rs`. README updated with the current falsifier matrix. No subprocess or model required — these are pure dispatcher changes that work in CI without GPU/model artifacts. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
5 tasks
noahgift
added a commit
that referenced
this pull request
May 13, 2026
Add two protocol-level invariants to the JSON-RPC dispatcher that must hold before method routing: - FALSIFY-MCP-005: requests with `jsonrpc != "2.0"` are rejected with `-32600 Invalid Request`. The check fires before method lookup so a malformed request to `initialize` / `tools/list` / `tools/call` cannot bypass version validation. - FALSIFY-MCP-007: `initialize.params.protocolVersion` mismatch returns `-32602 Invalid Params`. A missing field is permitted (some clients omit it on first handshake); only an actual mismatch is rejected. Positive case test guards against the guard accidentally tripping the happy path. 3 new integration tests in `tests/falsify_m1.rs`. README updated with the current falsifier matrix. No subprocess or model required — these are pure dispatcher changes that work in CI without GPU/model artifacts. Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
jsonrpc != "2.0"are rejected with-32600 Invalid Requestbefore method dispatch (FALSIFY-MCP-005)initialize.params.protocolVersionmismatch returns-32602 Invalid Params(FALSIFY-MCP-007). Missing field is permitted; only mismatch is rejected.Why
The MCP spec lists 8 falsifiers; we had 1, 2, and the validate-001 negative test. -005 and -006 are bucketed under M3 in the milestone checklist, but the content of -005 (malformed request handling) is dispatcher-level and independent of streaming. -007 (protocol-version mismatch) is similarly pure validation. Shipping these now closes two more gates without committing to M3 streaming work.
Test plan
cargo test -p aprender-mcp— 29 lib + 8 integration tests passcargo clippy -p aprender-mcp --all-targets -- -D warningscleancargo fmt -p aprender-mcp -- --checkclean🤖 Generated with Claude Code