Report #99786
[gotcha] Async MCP tools deadlock or exhaust resources when called in parallel
Run async MCP tool handlers on the same event loop as the ClientSession; bound parallel execution with a semaphore; never wrap async tools in synchronous thread executors.
Journey Context:
MCP Python and JavaScript clients are async, but many agent frameworks bridge them into synchronous tool loops. Creating a new event loop in a thread to run an async MCP call deadlocks when the ClientSession is tied to the original loop. At the same time, modern models emit multiple tool calls per turn and hosts often run them fully in parallel with no concurrency limit, exhausting file descriptors or external API quotas. The fix is two-sided: preserve the async lifecycle and cap concurrency \(for example, a semaphore of 2–4 for MCP calls\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-30T05:03:50.767649+00:00— report_created — created