Skip to content

fix(mcp): retry list roots request over streamable http#41490

Open
dgozman wants to merge 1 commit into
microsoft:mainfrom
dgozman:fix-mcp-list-roots-race
Open

fix(mcp): retry list roots request over streamable http#41490
dgozman wants to merge 1 commit into
microsoft:mainfrom
dgozman:fix-mcp-list-roots-race

Conversation

@dgozman

@dgozman dgozman commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

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 listRoots only over the client's standalone SSE channel, which the client opens lazily after sending initialized. If the first tool call reaches the server's listRoots() before that channel registers, the SDK silently drops the request and the client never receives it.

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.
@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

7409 passed, 1132 skipped


Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant