Skip to content

feat(mcp): M2 dispatcher hardening — FALSIFY-MCP-005 + -007 gates#868

Merged
noahgift merged 1 commit into
mainfrom
feat/apr-mcp-jsonrpc-version-gate
Apr 18, 2026
Merged

feat(mcp): M2 dispatcher hardening — FALSIFY-MCP-005 + -007 gates#868
noahgift merged 1 commit into
mainfrom
feat/apr-mcp-jsonrpc-version-gate

Conversation

@noahgift

Copy link
Copy Markdown
Contributor

Summary

  • Adds JSON-RPC version validation: requests with jsonrpc != "2.0" are rejected with -32600 Invalid Request before method dispatch (FALSIFY-MCP-005)
  • Adds protocol version negotiation: initialize.params.protocolVersion mismatch returns -32602 Invalid Params (FALSIFY-MCP-007). Missing field is permitted; only mismatch is rejected.
  • 3 new integration tests + happy-path positive case to guard against the new check tripping the normal flow.

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 pass
  • cargo clippy -p aprender-mcp --all-targets -- -D warnings clean
  • cargo fmt -p aprender-mcp -- --check clean
  • Pre-existing FALSIFY-MCP-001/-002/-VALIDATE-001 still pass (no behavior change to happy paths)

🤖 Generated with Claude Code

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>
@noahgift noahgift enabled auto-merge (squash) April 18, 2026 03:38
@noahgift noahgift merged commit 764248e into main Apr 18, 2026
11 checks passed
@noahgift noahgift deleted the feat/apr-mcp-jsonrpc-version-gate branch April 18, 2026 03:50
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant