Skip to content

fix(mcp): answer every unreadable JSON-RPC message with its spec error (#9016) - #9101

Merged
EffortlessSteven merged 7 commits into
mainfrom
claude/mcp-jsonrpc-conformance
Oct 21, 2026
Merged

EffortlessSteven merged 7 commits into
mainfrom
claude/mcp-jsonrpc-conformance

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Requested by Steven · project thread
Governing issue or accepted claim: #9016
Acceptance delta (one sentence): ripr mcp --stdio replies to every message it cannot type (Parse error, null/fractional id, over-deep or over-cap input) with the JSON-RPC/MCP-specified code, message and id, and ripr_list_gaps rejects an unknown language filter instead of returning an empty page.

Changes (verified by probing the stdio binary before and after)

Probe Before After
{not json no reply (hang) -32700 Parse error, id null
"id":null / "id":1.5 request no reply (SDK decodes it as a notification and ignores it) -32600, id null
5000-deep params no reply -32700, id null
over-cap message -32600, id always null -32600 with the request id when a top-level string/integer id lies in the first 4 KiB, else null
initialize without params on an initialized session -32601, message initialize -32602, invalid params for initialize: expected protocolVersion, capabilities and clientInfo
unknown method -32601, message = bare method name -32601 Method not found: <method>
unknown tool -32601 -32602 (MCP tools spec: unknown tool is Invalid Params)
ripr_list_gaps {"language":"cobol"} silent empty page -32602 listing rust, typescript, javascript, python, perl
jsonrpc:"1.0" request with a known id already echoes the id on current main (-32600, id kept) unchanged; pinned by new tests

Notes:

  • ADR 0022, docs/interop/mcp.md and RIPR-SPEC-0211 documented the old behavior ("syntax-invalid JSON is ignored", unknown tool = Method Not Found, unknown filter value = empty page); updated. The changed pins are mcp_stdio (unknown tool), mcp_sdk, agentic_bench_mcp, the transport "syntax ignore" unit test, and the unknown-language case in the filter test; the empty_gap_pages control no longer uses language as its filler filter.
  • class filter validation is deliberately left to fix(mcp): reject unknown class filter tokens in ripr_list_gaps #8697 (open); the unknown-class pins are untouched. fix(mcp): reject request ids over 16 KiB without ending the session #8681 also edits transport.rs receive(); whichever lands second resolves the textual conflict.
  • Pre-initialize unknown methods still get the SDK's _meta -32602 (unchanged).

Proof

  • Red: probe drivers against the pre-change binary showed the hangs and bare messages above.
  • Green: cargo test -p ripr --lib mcp:: (172 pass, incl. new unanswerable_frames_get_a_parse_or_invalid_request_reply_not_silence, oversized_frame_error_names_a_front_loaded_request_id, oversized_request_id_rejects_a_number_cut_by_the_prefix_end); cargo test -p ripr --test mcp_stdio --test mcp_sdk --test agentic_bench_mcp (15 + 4 + 23 pass, incl. new wire test json_rpc_rejections_are_answered_with_spec_codes_and_the_session_survives).
  • cargo xtask precommit: fmt, static-language, no-panic-family, allow-attributes, local-context, dependencies, process/network/lint policy gates pass; the run then hit a cargo-lock instrument timeout in the covered_by enumeration (shared target dir contended by many concurrent sessions), which is infrastructure, not a source failure. Remaining gates to be confirmed on hosted exact-head CI.

Review status: REVIEW_INCOMPLETE (no hosted proof yet); draft, not requesting merge.


Generated by Claude Code

#9016)

Parse errors (-32700), null/fractional ids (-32600), over-deep JSON and
oversized messages now get a reply instead of silence; an over-cap message
names its request id when a top-level id lies in its first 4 KiB. A repeated
initialize without params is -32602 with a useful message, unknown methods
read "Method not found: <method>", an unknown tool is -32602 (MCP), and
ripr_list_gaps rejects an unknown language filter with the allowed values.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019ZHDKLVQqArSZrUFKSkREo
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 30 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 86 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: 1526a44e-2b0f-430c-bf08-63cb9ddca5c9
📥 Commits

Reviewing files that changed from the base of the PR and between 601b3a4 and d39f360.

📒 Files selected for processing: 12
  • changelog.d/9016-mcp-jsonrpc-conformance.md
  • crates/ripr/src/mcp/framing.rs
  • crates/ripr/src/mcp/protocol.rs
  • crates/ripr/src/mcp/server.rs
  • crates/ripr/src/mcp/transport.rs
  • crates/ripr/src/mcp/transport_tests.rs
  • crates/ripr/tests/agentic_bench_mcp.rs
  • crates/ripr/tests/mcp_sdk.rs
  • crates/ripr/tests/mcp_stdio.rs
  • docs/adr/0022-mcp-is-a-bounded-projection.md
  • docs/interop/mcp.md
  • docs/specs/RIPR-SPEC-0211-mcp-workspace-session-evidence.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 21, 2026 05:25
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Copy link
Copy Markdown
Member Author

Spec check for the unknown-tool code, from the fetched MCP 2025-11-25 Tools page (https://modelcontextprotocol.io/specification/2025-11-25/server/tools): it lists unknown tools under "Protocol Errors: Standard JSON-RPC errors", and its only example is {"error":{"code":-32602,"message":"Unknown tool: invalid_tool_name"}}. It gives no normative prose code, and -32601 does not appear on the page. So -32602 matches the spec's example. Only this version was checked.

Independent review of f467947 found no blocking issues. I pushed 82a5f34 for two optional findings: the stale ADR unknown-tool row and an unbounded language echo in the error. Hosted CI is pending.


Generated by Claude Code

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 3 potential issues.

Devin Review

Comment thread crates/ripr/src/mcp/server.rs Resolved
Comment thread crates/ripr/src/mcp/transport.rs Resolved
Comment thread crates/ripr/src/mcp/framing.rs Resolved
…st_gaps schema (#9016)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019ZHDKLVQqArSZrUFKSkREo

Copy link
Copy Markdown
Member Author

CI on head 2a93213b (Rust-only feature lane, run 39549862362): 531 of 532 cli_smoke tests pass, and the one failure is selector_recovery_scope::selector_recovery_replays_committed_worktree_and_supplied_diff_scopes. That test is the known regression tracked in #9085 and fixed by #9069. This PR changes only MCP transport and server code, so it is not the cause. No fix exists on main yet to port. The 34 owner_pin_execution tests all passed on this run. Keeping merge-ready and the PR watched, with no code push for this failure. I'll re-check once #9069 lands.


Generated by Claude Code

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed findings

  • crates/ripr/src/mcp/transport_tests.rs:248 — syntax_error_and_typed_shape_error_are_each_answered_then_next_request_recovers reuses error_frames_for's decode path internally; add one case where the SDK untagged-decoder falls back to Notification because id is null, to pin carries_id_member -> -32600 reply rather than a silent drop.
  • The inherited Devin-0002 boundary-prefix id loss is permitted by JSON-RPC (id allowed null when undetectable), the precondition requires >256 KiB, and the change adds a 4 KiB prefix only to capture that id. No code defect relative to spec.
  • No coverage diff enumerates session behavior when a 4 KB-prefix over-cap message is followed by the rest of the same TCP read; framing.rs Oversized(Vec<u8>) discards remainder and the next-delimiter frame is consumed in a future read, but no test pins 'two messages back-to-back with one over-cap'.

Verification questions

  • Confirm oversized_request_id_rejects_a_number_cut_by_the_prefix_end proves numeric truncation but the symmetric string-truncation case is not pinned; author's PR-thread reply treats it as accepted behavior but no test asserts 'string id closing at the exact prefix end yields null id' to lock that contract against future regressions.
  • Confirm oversized_frame_error_names_a_front_loaded_request_id covers id-first front-loading, nested-id inside params, text-spelled id, and non-object; the exact 4096-byte closing-quote boundary case is not added.
  • Confirm devin's claimed boundary-length id (closing-quote at byte 4096, no trailing key) case is acknowledged by author as still id:null; oversized_request_id_rejects_a_number_cut_by_the_prefix_end covers numeric truncation but no string-truncation case exists.
  • Confirm unknown methods test exists only post-initialize (nope/never after init/initialized); pre-initialize unknown methods are documented to keep the SDK's _meta -32602. No stdio test asserts that contract.

Refuted

  • Self-collision: 'js-backed memory crossing worker' lane applied to a pure-Rust tokio diff with no JS/GC, detached Worker, or transferable handle.
  • The wire test would accept a wrong id because expected_id defaults to Null for most cases: the deep,v1 front-loaded,oversized,init-again,nope,unknown-tool,bad-language cases each pin a non-null expected_id in the exchanges table; refuted because: Each assertion in json_rpc_rejections_are_answered_with_spec_codes_and_the_session_survives checks id == expected for non-null ids; vector literal is exhaustive.

Evidence gaps

  • Hosted cargo-test receipt not yet in the packet; PR body acknowledges REVIEW_INCOMPLETE. The tokmd/ast-grep/unsafe-review base is fine but does not exercise the new stdio exchange or transport conformance tests.
  • Model proof intent was rejected by deterministic validation.
  • Without proof receipts (cargo-test scheduled-late, miri/heavy witnesses off), allocation-failure behavior on the 4 KiB prefix path is asserted only by the no-alloc oversized test, not by a sanitizer/miri witness.

Copy link
Copy Markdown
Member Author

Addendum for the same head 2a93213b: "Rust gates" (and so the required "Ripr Rust Small Result") fails at cargo nextest run --workspace --profile ci, and the three failing tests are all in analysis::classify::owner_pin::tests::json_construction (lines 107, 148 and 277 of owner_pin/tests/json_construction.rs). That is the main-wide serde_json fixture-cache failure, which this diff does not touch (it changes only the MCP transport, server and protocol files plus docs). The selected fix is #9069's deterministic locked fixture preparation. #9096, my alternative repin, was withdrawn in favor of it. The earlier-noted selector_recovery_scope failure belongs to #9085. Nothing here needs a code change. I'll merge main in and re-apply merge-ready once the main fix lands.


Generated by Claude Code

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed findings

  • No JS-backed memory crossing in this Rust-only MCP transport. Tokio Mutex<BufReader>/Mutex are Send where R: AsyncRead+Unpin+Send, W: AsyncWrite+Unpin+Send; the new pending_protocol_error: Option<Vec> is moved on the same task. There is no detach, no transfer, no GC root involved. Lane scope is satisfied by absence.
  • crates/ripr/tests/mcp_stdio.rs:437 — 'session_survives' is asserted with a single trailing ping; there is no assertion that ripr's stderr is silent or that the child did not exit non-zero after the 10 rejection exchanges (timeout-bounded reads only).
  • No TypedArray/ArrayBuffer detach or resize surface exists in the Rust MCP transport; the only resize is Vec::truncate on a single-owner buffer. No host-buffer transfer or detached-view aliasing plausible in this diff.

Verification questions

  • Confirm the existing tests cover oversized-frame discard followed by a separate read, but do not explicitly pin two complete frames delivered in one backing read when the first is over-cap.
  • Confirm frameReader::read_frame keeps the 4 KiB prefix through the new Oversized(Vec<u8>) arm; discard through the delimiter still happens in the same read, but the next frame is only proven for the same single read in oversized_frame_is_discarded_without_allocating_past_the_cap. A 'back-to-back: over-cap then small frame in one BufReader fill' is not pinned by any test.
  • Confirm devin-0002 unaddressed in code and unittest: string id closing exactly at byte 4096 yields id:null; author accepts by JSON-RPC rule but no regression test asserts 'string id terminating at the prefix end produces id:null'.
  • Confirm json_rpc_rejections_are_answered_with_spec_codes_and_the_session_survives uses synthetic SDK 'ping' as alive-check; tool args filtered through SDK CallToolRequestParams skip the transport-level raw byte path that real clients exercise.
  • Confirm stderr-suppression and exit non-zero on repeatedly-malformed frames remain unproved: stdio harness tolerance for the new '-32700 / -32600' replies per bad frame is not exercised; client-side hang or hang-to-exit is the failure mode the PR claims to fix.
  • Confirm ripr sensor failed (exit 2) and is not retried in this packet; behavioural cargo-test lease is scheduled-late only, so the lane cannot independently confirm greenness for mcp_sdk/mcp_stdio/agentic_bench_mcp on hosted CI.
  • Confirm unanswerable_frames_get_a_parse_or_invalid_request_reply_not_silence pins carriage-shape id preservation across SDK codec failure; pins the front-loaded id and null id paths the prefix parser takes.

Refuted

  • ripr_list_gaps language enum must also reject empty strings beyond the new dispatch, but the schema only excludes empty via minLength; refuted because: Inspecting protocol.rs: enum values are taken from LanguageId::ALL which has no empty wire string; minLength:1 plus enum union already excludes "" deterministically, no extra path needed.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.

Resolve transport_tests.rs and mcp_stdio.rs conflicts keeping both sides.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019ZHDKLVQqArSZrUFKSkREo

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed findings

  • ADR 0022 still documents 'syntax-invalid JSON is ignored' as a Prior control note wording in the table footer for one row; only the table cell was rephrased. Interop doc and SPEC 0211 were updated, but if any external downstream pins the footer line, sibling docs drift; leave to a docs owner.

Verification questions

  • Confirm error_frames_for drives BoundedTransport::receive end-to-end; framing.rs framing discards the byte after the delimiter (consume through newline) so a second complete frame delivered in the same read is consumed in the next call, not in this one. The 'two messages back-to-back with one over-cap' invariant is not pinned by a test in this diff and is referenced in the seeded GitHub-actions review as unverified.
  • Confirm oversized id extraction is pinned for front-loaded id, id after prefix, nested id, id-in-string, and non-object; string-id closing exactly on byte 4096 is NOT pinned.
  • Confirm two complete frames back-to-back in one read where the first is over-cap is not pinned, and mcp_stdio.rs 'session_survives' asserts only a single trailing ping (no child-exit / stderr-silence check).

Refuted

  • The malformed-input repair path could retain a pointer into a reused or mutated frame buffer.; refuted because: All returned protocol errors own their serialized bytes, while oversized_request_id creates a temporary Deserializer over the prefix and returns only an owned serde_json::Value. No reference escapes its call.
  • The unknown-language rejection breaks schema/runtime parity.; refuted because: The changed descriptor enum and server validation both derive from LanguageId::ALL, and the prior schema-parity objection was fixed in the current head.
  • Over-cap string id whose closing quote lands on byte 4096 lets attacker corrupt id correlation by reading as a different id; refuted because: Devin-0002 hypothesis. Designer-required IgnoredAny next_key in oversized_request_id forbids reassignment; JSON-RPC explicitly allows null when undetectable. Failing window is single-byte and adds no attack surface beyond DoS, which the cap already mitigates.

Evidence gaps

  • Exact-head runtime evidence is not complete because the ripr sensor failed and cargo-test remains scheduled.
  • Model proof intent was rejected by deterministic validation.
  • Exact-head hosted/central cargo-test evidence is still absent, so the local test claims remain PR-body evidence rather than a completed repository witness.
  • Exact-head execution proof is not yet present in the packet.

Parked follow-ups

  • No observed code path shrinks a buffer that another handle still observes a length of: pending_protocol_error is taken once by receive() and either handed to frame_writer.send_response_frame (which writes the bytes synchronously) or replaced. No shared slice, no detach. Lane scope satisfied by absence; JsonRpcMessageCodecError import removed from transport.rs in the same diff.

Resolve ADR 0022 compatibility paragraph keeping both sides.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019ZHDKLVQqArSZrUFKSkREo

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed findings

  • crates/ripr/tests/mcp_stdio.rs:322 — Extend the stdio rejection test to assert that stderr remains quiet and the child is still healthy after the rejection sequence, not only that a final ping returns. Otherwise a transport that logs protocol failures or exits after processing could still pass this oracle.

Verification questions

  • Confirm the transport recovery test uses separate backing inputs rather than proving recovery when malformed/oversized data and a valid frame are delivered in one read.
  • Confirm the stdio rejection test validates responses but not stderr silence or nonzero child exit after ten rejection exchanges.
  • Confirm oversized frames retain only the leading 4 KiB and transport-level JSON parsing preserves the prior recover-next-frame behavior while producing a protocol error.
  • Confirm oversized-frame remainder versus the next-read frame is consumed in a future FrameReader::read_frame call, not in the same receive() turn; framing.rs discards through the newline. No test pins 'two complete frames delivered in one backing read when the first is over-cap'.
  • Confirm the SDK notification-fallback regression remains unpinned end-to-end.
  • Confirm a back-to-back over-cap frame followed by a complete frame in one backing read is plausible but not explicitly pinned; current tests prove discard followed by a separate read.
  • Confirm framing recovery is tested across separate reads, not two frames delivered in one backing read.
  • Confirm two complete frames back-to-back in one read where the first is over-cap is not pinned by a test; framing discards through the delimiter so the next frame is consumed by a future read, leaving no aliasing or buffer-sharing risk.

Refuted

  • The language schema/runtime disagreement is still an actionable defect.; refuted because: The descriptor now emits LanguageId::ALL as an enum, the stdio test exercises cobol rejection, and the seeded thread records that the review comment was answered by that change.

Evidence gaps

  • The strongest remaining proof gap is not a demonstrated defect: exact-head cargo-test evidence is unavailable, so hosted CI must confirm the reported wire and recovery behavior on the final commit.
  • Model proof intent was rejected by deterministic validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants