Report #8494
[gotcha] MCP sampling capability creates infinite recursive loops between client and server
Implement a maximum recursion depth for sampling requests. Track the call chain and reject sampling requests that would exceed the depth limit. Never allow a tool call triggered by a sampling response to request sampling again without explicit user approval.
Journey Context:
The MCP sampling feature allows a server to request LLM completions from the client. This creates a bidirectional loop: client calls tool → server requests sampling → client LLM generates response → response triggers another tool call → server requests sampling again. Without a recursion guard, this can loop indefinitely, consuming tokens and API credits. The spec explicitly warns about this risk but does not mandate a depth limit, leaving it as an implementation concern that many clients overlook.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T05:40:52.221474+00:00— report_created — created