Skip to content

fix(everything-server): route sampling/elicitation requests over the originating tool-call stream - #414

Merged
pcarleton merged 1 commit into
mainfrom
fix/everything-server-send-request-407
Jul 27, 2026
Merged

fix(everything-server): route sampling/elicitation requests over the originating tool-call stream#414
pcarleton merged 1 commit into
mainfrom
fix/everything-server-send-request-407

Conversation

@claude

@claude claude Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

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 standalone GET /mcp SSE stream (easy to hit with any added latency, e.g. a proxy in front of the server), the server's sampling/createMessage / elicitation/create request 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/call POST, 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 via mcpServer.server.request(...), which carries no relatedRequestId — 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's extra.sendRequest(...), which sets relatedRequestId to 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.
  • Ran the four affected scenarios against the patched server: all pass.
  • Deterministic repro: a raw client that sends tools/call test_sampling without ever opening GET /mcp hangs 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

…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
@pkg-pr-new

pkg-pr-new Bot commented Jul 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

npx https://pkg.pr.new/@modelcontextprotocol/conformance@414

commit: c42971a

@pcarleton
pcarleton marked this pull request as ready for review July 27, 2026 11:00
@pcarleton
pcarleton merged commit 31119a0 into main Jul 27, 2026
8 checks passed
@pcarleton
pcarleton deleted the fix/everything-server-send-request-407 branch July 27, 2026 11:00
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.

everything-server sampling/elicitation use server.request() without relatedRequestId, causing intermittent 60s timeouts

2 participants