Repository navigation
fix(mcp): answer every unreadable JSON-RPC message with its spec error (#9016) - #9101
Conversation
#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
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
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. View limit details
Comment |
…row (#9016) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZHDKLVQqArSZrUFKSkREo
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
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 Independent review of f467947 found no blocking issues. I pushed 82a5f34 for two optional findings: the stale ADR unknown-tool row and an unbounded Generated by Claude Code |
…st_gaps schema (#9016) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ZHDKLVQqArSZrUFKSkREo
|
CI on head Generated by Claude Code |
There was a problem hiding this comment.
Confirmed findings
- crates/ripr/src/mcp/transport_tests.rs:248 —
syntax_error_and_typed_shape_error_are_each_answered_then_next_request_recoversreuseserror_frames_for's decode path internally; add one case where the SDK untagged-decoder falls back to Notification becauseidis null, to pincarries_id_member->-32600reply 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.
|
Addendum for the same head Generated by Claude Code |
There was a problem hiding this comment.
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 inoversized_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::ALLwhich 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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Requested by Steven · project thread
Governing issue or accepted claim: #9016
Acceptance delta (one sentence):
ripr mcp --stdioreplies 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, andripr_list_gapsrejects an unknownlanguagefilter instead of returning an empty page.Changes (verified by probing the stdio binary before and after)
{not json-32700 Parse error, id null"id":null/"id":1.5request-32600, id nullparams-32700, id null-32600, id always null-32600with the request id when a top-level string/integeridlies in the first 4 KiB, else nullinitializewithout params on an initialized session-32601, messageinitialize-32602,invalid params for initialize: expected protocolVersion, capabilities and clientInfo-32601, message = bare method name-32601 Method not found: <method>-32601-32602(MCP tools spec: unknown tool is Invalid Params)ripr_list_gaps {"language":"cobol"}-32602listingrust, typescript, javascript, python, perljsonrpc:"1.0"request with a known id-32600, id kept)Notes:
docs/interop/mcp.mdand 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 aremcp_stdio(unknown tool),mcp_sdk,agentic_bench_mcp, the transport "syntax ignore" unit test, and the unknown-languagecase in the filter test; theempty_gap_pagescontrol no longer useslanguageas its filler filter.classfilter validation is deliberately left to fix(mcp): reject unknown class filter tokens in ripr_list_gaps #8697 (open); theunknown-classpins are untouched. fix(mcp): reject request ids over 16 KiB without ending the session #8681 also editstransport.rsreceive(); whichever lands second resolves the textual conflict._meta-32602(unchanged).Proof
cargo test -p ripr --lib mcp::(172 pass, incl. newunanswerable_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 testjson_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 thecovered_byenumeration (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