MCP 2026-07-28 (1/11): protocol foundations — versions, typed errors, resultType - #224
Open
simonx1 wants to merge 4 commits into
Open
MCP 2026-07-28 (1/11): protocol foundations — versions, typed errors, resultType#224simonx1 wants to merge 4 commits into
simonx1 wants to merge 4 commits into
Conversation
…ltType Lay the groundwork for the stateless 2026-07-28 revision: - LATEST/MODERN/LEGACY protocol version constants; SUPPORTED is their union and initialize only accepts a legacy negotiated version. - ServerError carries the JSON-RPC code and data; ServerError.from_jsonrpc builds HeaderMismatchError (-32020), MissingRequiredClientCapabilityError (-32021) and UnsupportedProtocolVersionError (-32022). Errors::Codes holds the allocation-policy constants. - process_jsonrpc_response validates resultType: absent means complete, unrecognized values raise InvalidResultError (a non-retried ServerError). Stdio now routes every response through it so codes are preserved. - resources/read errors with -32602 (or legacy -32002) raise ResourceNotFound on every transport. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MoErzDypnq7hhuFBtueML7
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Codex review: only callers of process_jsonrpc_response checked resultType. ServerSSE#check_for_result returned the stored result directly and the stdio initialize handshake read res['result'] itself, so an unrecognized resultType passed through on those paths. Both now run the same validation; a stdio initialize error still surfaces as ConnectionError. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MoErzDypnq7hhuFBtueML7
2 tasks
…ot-found Review findings (grok): - HTTP, Streamable HTTP and SSE discarded the JSON-RPC body of a 4xx, so the 2026-07-28 protocol errors (-32020/-32021/-32022, which the spec requires servers to send with HTTP 400) never became typed errors and a dual-era client could not recognize a modern server. The body is now parsed (gzip-aware) and the typed error raised with the HTTP status in the message; 5xx stays TransientServerError. - resources/read -32602 only means not-found on a modern session; on a legacy (2025-11-25) session it remains generic Invalid params. Added protocol_version/modern? readers to JsonRpcCommon for the gate. - A stdio initialize rejected with UnsupportedProtocolVersionError now names the versions the server supports; initialize answering with a modern version is covered by a test. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MoErzDypnq7hhuFBtueML7
…and raise_error Second review round (codex + grok): - Only a JSON-RPC 2.0 error body carrying the data its schema mandates (data.supported for -32022, data.requiredCapabilities for -32021) counts as a recognized modern error, so a bare -3202x from a legacy endpoint or intermediary cannot suppress the fallback. ServerError#http_status records the HTTP status the error arrived with. - Faraday raise_error middleware no longer bypasses body inspection: a 4xx raised as Faraday::ClientError is parsed like the response path and never becomes a retryable TransportError. - HTTP error bodies are inspected only up to 64 KiB (gzip expansion included); larger bodies yield a plain ServerError without parsing. - Protocol-level errors (the typed -3202x errors and InvalidResultError, ServerError#protocol_error?) propagate through call_tool, get_prompt, read_resource and every stdio public method instead of being wrapped into ToolCallError and friends, so requiredCapabilities and supported versions reach the host. - A modern result must be an object; an explicit null resultType is invalid in either era. Legacy bare-array results stay tolerated. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MoErzDypnq7hhuFBtueML7
simonx1
force-pushed
the
mcp-2026/protocol-foundations
branch
from
September 1, 2026 18:59
b211916 to
8ca799c
Compare
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
First of a stacked series implementing the MCP 2026-07-28 revision. This PR lays the base-protocol groundwork the later feature PRs build on; nothing changes on the wire yet.
LATEST_PROTOCOL_VERSION(2026-07-28),MODERN_PROTOCOL_VERSIONS,LEGACY_PROTOCOL_VERSIONS;SUPPORTED_PROTOCOL_VERSIONSis their union.PROTOCOL_VERSIONstays2025-11-25(the legacyinitializerequest version), andinitializenow only accepts a legacy negotiated version.Errors::Codesconstants;ServerErrorgainscode/data(backward-compatible ctor);ServerError.from_jsonrpcbuilds the typedHeaderMismatchError(-32020),MissingRequiredClientCapabilityError(-32021,#required_capabilities) andUnsupportedProtocolVersionError(-32022,#supported/#requested). All four transports raise them; stdio now routes every response throughprocess_jsonrpc_responseso codes are never dropped.resultType— absent ⇒"complete"(earlier-protocol servers),"input_required"passes through (handled by the MRTR PR), anything unrecognized raisesInvalidResultError(a non-retriedServerError). Transports can widen the accepted set viaaccepted_result_types(used by the tasks extension PR).resources/readerrors with-32602(or legacy-32002) raiseResourceNotFoundon every transport.Spec references
Test plan
bundle exec rspec— 1701 examples, 0 failures (44 new)bundle exec rubocop— clean🤖 Generated with Claude Code
https://claude.ai/code/session_01MoErzDypnq7hhuFBtueML7