Report #72270
[gotcha] MCP server hangs indefinitely on large responses over stdio transport
Always read server stdout asynchronously and non-blockingly. For servers returning large payloads, prefer the Streamable HTTP transport over stdio. If stdio is required, implement flow control: chunk large responses and ensure the client drains the pipe between chunks.
Journey Context:
The stdio transport uses OS pipes for client-server communication. OS pipes have finite buffer sizes \(64KB typical on Linux, 4KB on some systems\). When an MCP server writes a response larger than the pipe buffer, the write\(\) syscall blocks until the client reads. If the client is synchronously waiting for a response without concurrently reading stdout — a common pattern in naive implementations — both sides deadlock: the server blocks on write, the client blocks on read. This is especially insidious because it only manifests with large tool results \(e.g., file reads, search results\) and works fine in testing with small payloads. The Streamable HTTP transport avoids this entirely by using HTTP semantics with proper flow control.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T03:53:32.648295+00:00— report_created — created