Gate 2026-07-28 result fields on negotiated protocol version (#1721) - #1753
Merged
tarekgh merged 1 commit intoJul 27, 2026
Merged
Conversation
…ntextprotocol#1721) The server unconditionally stamped resultType, ttlMs, and cacheScope on every JSON-RPC result, which are exclusive to the 2026-07-28 revision. Strict 2025-11-25 clients (such as MCP Inspector 1.0.0) reject these unrecognized keys and fail the handshake. Every stamping site is now gated on the negotiated (or per-request) protocol version: - SetHandler and SetWithAlternateHandler only stamp resultType, ttlMs, and cacheScope when the request is 2026-07-28 or later. - InitializeResult no longer hardcodes resultType (the initialize handshake only ever negotiates 2025-11-25 or earlier). - The default logging/setLevel handler returns a fresh EmptyResult instead of the shared, pre-stamped EmptyResult.Instance, so this legacy method no longer leaks resultType to down-level clients. Added Core and raw HTTP wire regression tests, and updated existing down-level assertions accordingly. Copilot-Session: 80653343-5dcb-43cb-89b0-8ac8e572c4f7
Contributor
Author
|
CC @p-ob |
halter73
approved these changes
Jul 27, 2026
halter73
left a comment
Contributor
There was a problem hiding this comment.
Custom handlers and filters can still explicitly set resultType or cache hints for legacy requests, producing invalid wire shapes. I filed #1754 to decide whether we should reject, warn and strip, or silently strip those values. This shouldn’t block this release fix.
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.
Fixes #1721.
The server unconditionally stamped
resultType,ttlMs, andcacheScopeon every JSON-RPC result. These fields are exclusive to the 2026-07-28 revision, so strict 2025-11-25 clients (such as MCP Inspector 1.0.0) reject them as unrecognized keys and fail the handshake.This change gates every stamping site on the negotiated (or per-request) protocol version:
SetHandlerandSetWithAlternateHandleronly stampresultType,ttlMs, andcacheScopewhen the request is 2026-07-28 or later.InitializeResultno longer hardcodesresultType(the initialize handshake only ever negotiates 2025-11-25 or earlier).logging/setLevelhandler returns a freshEmptyResultinstead of the shared, pre-stampedEmptyResult.Instance, so this legacy method no longer leaksresultTypeto down-level clients.The 2026-07-28-only paths (
server/discover,subscriptions/listen, and the Tasks extension) keep stamping these fields as required by the spec.Testing
tools/listandtools/callon both 2025-11-25 (fields omitted) and 2026-07-28 (fields present) sessions.InitializeResultand a down-leveltools/list.logging/setLevelregression test.