Repository navigation
fix(streamable-http-client): handle error responses to initialize - #1361
Merged
DaleSeo merged 3 commits intoOct 15, 2026
Merged
Conversation
expect_initialized only stopped draining an SSE response on a result, so an error event for initialize was skipped. serve() then reported ConnectionClosed, or hung if the server kept the stream open. perform_reinitialization also ignored an error reply and went on to send notifications/initialized and retry the expired request without a session. It now returns the error, which fails the pending requests. Fixes modelcontextprotocol#1360
Contributor
|
@bolinfest is on triage rotation this week and is the reviewer for this one. Labels come from the PR labeler. Please review the change. Automated triage. Labels are a first pass and the assigned maintainer has the final say. |
DaleSeo
previously approved these changes
Oct 15, 2026
DaleSeo
left a comment
Member
There was a problem hiding this comment.
Thanks for the fix, @gocamille! I only have a minor suggession.
DaleSeo
approved these changes
Oct 15, 2026
This was referenced Oct 15, 2026
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 #1360
expect_initializednow stops draining an SSE response on an error as well as a result, so the error reaches the service layer andserve()returnsClientInitializeError::JsonRpcError, the same as it already does forapplication/json.perform_reinitializationnow returns an error when the re-sentinitializegets an error reply, before it sendsnotifications/initialized. The worker's existing recovery-failure path then fails the pending requests, so nothing is retried without a session. I reusedUnexpectedServerResponsefor this rather than adding a variant, since recovery errors reach callers asTransportSendanyway and the message carries the server's code and text.The new tests in
test_streamable_http_initialize_error.rsuse an axum mock server:The two re-init tests check the full list of POSTs the server receives, so they fail if
notifications/initializedor the retried request goes out after the error.Validation
mainand pass with the change.cargo test -p rmcp --all-features: passed.cargo clippy --all-targets --all-features -- -D warningsandcargo +nightly fmt --all -- --check: clean.