Report #90547
[gotcha] MCP server sends sampling request to client, but client does not support sampling or user never responds, causing server to hang forever
Always implement a timeout on server-side sampling requests. Check client capabilities \(specifically the \`sampling\` capability\) during initialization before issuing sampling requests. If the client does not advertise sampling support, fall back to a default behavior rather than hanging. Use a reasonable deadline \(30-60 seconds\) and treat timeout as a rejection.
Journey Context:
MCP's sampling feature lets servers request LLM completions through the client, enabling human-in-the-loop and multi-step reasoning patterns. But if the client does not support sampling — which many do not — or the user walks away from the approval dialog, the server's request hangs with no timeout in the spec. There is no standard mechanism for the server to cancel a pending sampling request. The server process appears frozen, and there is no error to surface. This is a classic distributed systems gotcha: a synchronous request over an async protocol with no deadline. The alternative of making sampling fully async \(fire-and-forget\) loses the return value, which defeats the purpose. The right call is defensive timeouts plus capability checking.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T10:34:43.400987+00:00— report_created — created