fix(everything-server): route sampling/elicitation requests over the originating tool-call stream - #414
Merged
Conversation
…sendRequest Tool handlers issued sampling/createMessage and elicitation/create via mcpServer.server.request(), which carries no relatedRequestId. The SDK's Streamable HTTP transport routes such requests to the standalone GET SSE stream; if the client hasn't opened it yet, the request is silently parked in the event store and the scenario times out after 60s. Switch test_sampling, test_elicitation, test_elicitation_sep1034_defaults, and test_elicitation_sep1330_enums to the handler's extra.sendRequest(), which sets relatedRequestId so the request rides the originating tools/call POST SSE stream. Fixes #407 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Qz5WunPTnDHVot4C2J6sFz
commit: |
pcarleton
approved these changes
Jul 27, 2026
pcarleton
marked this pull request as ready for review
July 27, 2026 11:00
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.
Requested by Paul Carleton · Slack thread
Before: scenarios that exercise server-initiated requests against the everything-server (
tools-call-sampling,tools-call-elicitation,elicitation-sep1034-defaults,elicitation-sep1330-enums) could intermittently hang and fail with a ~60s request timeout. Whenever the tool handler ran before the client had opened the standaloneGET /mcpSSE stream (easy to hit with any added latency, e.g. a proxy in front of the server), the server'ssampling/createMessage/elicitation/createrequest was silently parked in the event store and never delivered.After: those scenarios complete deterministically. The server→client request is delivered on the SSE stream of the originating
tools/callPOST, which is guaranteed to be open for the duration of the handler, so it no longer matters whether or when the client opens the standalone GET stream.How: the four tool handlers in
examples/servers/typescript/everything-server.ts(test_sampling,test_elicitation,test_elicitation_sep1034_defaults,test_elicitation_sep1330_enums) issued their server→client requests viamcpServer.server.request(...), which carries norelatedRequestId— the SDK's Streamable HTTP transport routes such messages to the standalone GET stream, and silently stores-and-returns if that stream isn't connected. They now use the handler'sextra.sendRequest(...), which setsrelatedRequestIdto the in-flight tool-call id so the SDK associates the request with the open POST response stream. Schemas, result handling, and error handling are unchanged.Verification:
npm run typecheck,npm run lint,npm run build,npm test(442 tests) all pass.tools/call test_samplingwithout ever openingGET /mcphangs on the unpatched server (request never delivered) and succeeds on the patched one (request arrives on the POST SSE stream).Fixes #407
🤖 Generated with Claude Code
https://claude.ai/code/session_01Qz5WunPTnDHVot4C2J6sFz
Generated by Claude Code