Repository navigation
fix: handle ping requests sent before initialize handshake - #745
Merged
Merged
Conversation
DaleSeo
force-pushed
the
feat/ping-before-initialize
branch
from
March 11, 2026 13:31
398377a to
56f5784
Compare
DaleSeo
marked this pull request as ready for review
March 11, 2026 13:31
alexhancock
approved these changes
Mar 11, 2026
Merged
This was referenced Oct 14, 2026
gocamille
added a commit
to gocamille/rust-sdk
that referenced
this pull request
Oct 16, 2026
expect_response dropped a server ping while waiting for the initialize response, so the ping never got a reply. Answer it with an empty result during the initialize wait, the same way the server answers an early client ping. The server/discover wait still leaves it unanswered. Refs modelcontextprotocol#745 Fixes modelcontextprotocol#1362
gocamille
added a commit
that referenced
this pull request
Oct 16, 2026
) * fix(client): answer a server ping during the initialize handshake expect_response dropped a server ping while waiting for the initialize response, so the ping never got a reply. Answer it with an empty result during the initialize wait, the same way the server answers an early client ping. The server/discover wait still leaves it unanswered. Refs #745 Fixes #1362 * test(client): drop duplicated discover ping comment * refactor(client): replace answer_ping bool with PreInitPing enum * test(client): assert notifications/initialized follows the ping response * refactor(client): match on PreInitPing instead of comparing it The compiler now flags this spot if PreInitPing gains a variant, and the PartialEq and Eq derives are no longer needed.
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.
Closes #488
Motivation and Context
The MCP spec explicitly permits clients to send
pingbefore theinitializerequest, but the Rust SDK was rejecting any such message with anExpectedInitializeRequesterror. This caused cross-SDK incompatibility with the TypeScript SDK, which probes connectivity with a ping before starting the handshake.How Has This Been Tested?
Two new integration tests were added.
Breaking Changes
None. The server now accepts an additional valid message sequence that was previously rejected in error.
Types of changes
Checklist