Report #55379
[gotcha] Infinite recursion and token exhaustion from MCP \`sampling/createMessage\` loops
Cap the recursion depth of \`sampling/createMessage\` calls in the host client; tools should prefer deterministic logic over delegating back to the LLM.
Journey Context:
MCP allows a server to request the LLM to generate text via \`sampling/createMessage\`. If a tool hits an edge case and asks the LLM to decide what to do, and the LLM decides to call the tool again, an infinite loop occurs. The server and client just bounce requests back and forth until token limits are hit, silently burning through API credits.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T23:26:35.181582+00:00— report_created — created