fix(server): gate resource not found errors by protocol version - #973
Open
Jokasa7 wants to merge 1 commit into
Open
fix(server): gate resource not found errors by protocol version#973Jokasa7 wants to merge 1 commit into
Jokasa7 wants to merge 1 commit into
Conversation
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.
Implements the server-side resource-not-found error selection from SEP-2164 while preserving the behavior of currently negotiated 2025 protocol versions.
RESOURCE_NOT_FOUND(-32002) through MCP 2025-11-25INVALID_PARAMS(-32602) for MCP 2026-07-28 and laterdata.uripayloadMotivation and Context
Refs #805. Related lifecycle work: #815.
SEP-2164 standardizes an unknown
resources/readURI as JSON-RPCINVALID_PARAMSfor the 2026-07-28 specification. Applying that code unconditionally would change the wire behavior of clients that negotiate one of the SDK's currently supported 2025 protocol versions.This change therefore makes the decision at the server boundary using the version retained from initialization. The ISO
YYYY-MM-DDcomparison follows the compatibility approach already used by the official C# and Rust SDK implementations. Unsupported initialization versions still fall back toLATEST_PROTOCOL_VERSION, so they cannot accidentally opt into a future error contract.How Has This Been Tested?
gradlew.bat ktlintCheck detekt apiCheck— passed (173 tasks; 80 executed and 93 up-to-date).JsonRpcTest,ResourceNotFoundErrorCodeTest, andServerSessionAssertCapabilityTest— 29 passed.ServerResourceTemplateTestand the stdio, SSE, and Streamable HTTPResourceIntegrationTestvariants — 47 passed, 0 failed, 0 skipped.ProcessBuilder("npx", ...)does not resolve the installed Windowsnpx.cmd; the affected resource integrations were therefore rerun successfully under Linux, wherenpxis executable.The 2026+ decision branch is unit-tested, but full 2026-07-28 wire-level coverage is not yet reachable because this SDK does not currently negotiate the modern lifecycle. That end-to-end path depends on #815; this PR does not claim complete 2026-07-28 conformance.
Breaking Changes
There is no behavior change for the SDK's currently supported 2025 protocol versions: missing resources continue to return
-32002.Once a session can negotiate MCP 2026-07-28 or later, the same condition will intentionally return
-32602as required by SEP-2164. The publicRESOURCE_NOT_FOUNDconstant remains available with its legacy-32002value.Types of changes
Checklist
Additional context
This contribution was developed with Codex assistance. The implementation was checked against #805, SEP-2164, the current protocol-version negotiation behavior, and official C# and Rust SDK precedents, then verified with the focused checks above.