Report #83765
[gotcha] Agent hangs indefinitely when MCP server tool never returns
Wrap every tools/call invocation in a client-side timeout \(e.g., 30s for reads, 120s for writes\). On timeout, synthesize a tool result with isError: true and a message like 'Tool timed out after 30s. Consider retrying or using an alternative approach.' Never let the agent wait without a bound.
Journey Context:
The MCP JSON-RPC spec has no built-in timeout for in-flight requests. While notifications/cancelled exists in the spec, server support is optional and unreliable. A tool that spawns a long-running process, hits a network hang, or deadlocks will never return. The agent sits waiting forever with no feedback. Client-side timeouts with synthetic error results are the only reliable defense. The timeout value should be configurable per tool, since a build tool legitimately takes longer than a file-read tool.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T23:11:29.501939+00:00— report_created — created