Repository navigation
fix: keep initialize on legacy protocol versions - #1228
Merged
Merged
Conversation
DaleSeo
marked this pull request as ready for review
August 28, 2026 13:33
alexhancock
approved these changes
Aug 31, 2026
Merged
puretensor
added a commit
to PureTensorAI/ptask
that referenced
this pull request
Sep 6, 2026
rmcp 3.2.0 treats any initialize as a legacy handshake and keeps it on the session path (modelcontextprotocol/rust-sdk#1228). pTask's /mcp mount is StreamableHttpService; 3.1.4 could accept a 2026-07-28 initialize and then handle the session with modern-lifecycle semantics.
This was referenced Sep 9, 2026
JMLX42
added a commit
to lx-industries/rmcp-actix-web
that referenced
this pull request
Nov 11, 2026
Raise both rmcp requirements from 3.0.0 to 3.9.0, and update rmcp and rmcp-macros in Cargo.lock from 3.1.4 to 3.9.0. rmcp 3.9.0 adds sha2 0.11.1 as a new dependency. rmcp 3.4.0 deprecates the ServerInfo type alias and names ServerConfig as its replacement. Both alias InitializeResult, so the rename changes no type. Two tests follow behavior that rmcp changed upstream: - An initialize request that names 2026-07-28 is answered with 2025-11-25, the newest version that still has the handshake. A 2026-07-28 peer therefore sends no initialize: the resultType test now starts with its per-request tools/call. - A session-mode POST without Mcp-Session-Id that is not an initialize request is answered 400 Bad Request, body "Bad Request: Session ID is required", instead of 422. Upstream: modelcontextprotocol/rust-sdk#1156 modelcontextprotocol/rust-sdk#1266 modelcontextprotocol/rust-sdk#1228 modelcontextprotocol/rust-sdk#1377 Refs: #63
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 #1209.
Motivation and Context
The 2026-07-28 versioning spec is very clear about how a server that supports both eras should behave.
Two parts of the implementation broke that contract:
negotiate_protocol_versionreturned the client's requested version wheneversupported_protocol_versions()included it. That also applied to2026-07-28and later, even though those versions do not use a handshake.In the Streamable HTTP tower service,
is_legacy_requestused theprotocolVersionfrom theinitializebody to decide between session and stateless routing. As a result, a2026-07-28handshake took the stateless path and did not create a session. The server then accepted a legacy-lifecycle request but handled it with modern-lifecycle semantics.The fix makes these two parts consistent. Any
initializerequest is treated as a legacy client, regardless of the version it names. It always uses the session path and negotiates a version that still supports the handshake.If the server does not support any such version, it now returns
-32022 UnsupportedProtocolVersionErrorand identifies the versions it does support. This is also what the same spec page recommends. A server that supports only modern versions should name those supported protocol versions in any error returned for aninitializerequest.How Has This Been Tested?
Added tests
Breaking Changes
There is no public API change and no change to any lifecycle defined by the spec.
initializenever legitimately produced a 2026-07-28 session, so nothing that followed the spec could have depended on it.Code that used the handshake to reach a modern peer should switch to
ClientLifecycleMode::DiscoverorAuto. Alternatively, it can useserve_directlywith the version that was already agreed on. Seven tests in this repo took that shortcut and have been migrated toserve_directly, following the pattern already used intest_mrtr_behavior.rs.Types of changes
Checklist