fix(mcp): retry list roots request over streamable http#41490
Open
dgozman wants to merge 1 commit into
Open
Conversation
The MCP SDK delivers server-initiated requests (like listRoots) only over the client's standalone SSE channel, which the client opens lazily after sending the `initialized` notification. When the first tool call races ahead of that, the server has no stream to send listRoots on and the SDK silently drops it, so the client never receives the request. Use a short timeout and retry once, by which point the SSE channel is established. This fixes frequent flaking of the `client should receive list roots request` test on CI.
Contributor
Test results for "MCP"7409 passed, 1132 skipped Merge workflow run. |
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.
Restores #37324, which was removed in #37399. This still happens on the bots, see the flaky test
tests/mcp/http.spec.ts:349 > client should receive list roots request.Fixes a race: the MCP SDK delivers
listRootsonly over the client's standalone SSE channel, which the client opens lazily after sendinginitialized. If the first tool call reaches the server'slistRoots()before that channel registers, the SDK silently drops the request and the client never receives it.