Report #14268
[gotcha] MCP server on stdio transport hangs indefinitely, no error, no timeout
Use non-blocking or async I/O on both sides of the stdio pipe. On the server side, never write large payloads to stdout without the client actively draining. On the client side, always read server stdout in a dedicated thread or async task independent of stdin writes. Alternatively, prefer the SSE or Streamable HTTP transport for servers that return large payloads.
Journey Context:
The MCP stdio transport uses the server's stdin for client-to-server messages and stdout for server-to-client messages. This is a classic Unix pipe scenario: if the server writes a large response to stdout and the OS pipe buffer \(typically 64KB on Linux\) fills up because the client isn't reading, the server's write\(\) call blocks. But the client might be waiting to write the next request to stdin. Deadlock. No error is raised because neither side has failed—they are both legitimately waiting. This is extremely hard to reproduce in testing \(small responses fit in the buffer\) and only manifests in production with large tool results or rapid sequential calls. The SSE and Streamable HTTP transports avoid this by decoupling the channels.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T21:10:48.324896+00:00— report_created — created