Report #24508
[tooling] MCP server hangs indefinitely when returning large JSON responses \(>64KB\) over stdio transport
Implement chunked writing with explicit flush after each chunk, switch to SSE transport for payloads >64KB, or use stdbuf -o0 on POSIX to disable buffering. Never write >64KB in a single JSON-RPC batch without ensuring the client is reading concurrently.
Journey Context:
POSIX pipe buffers default to 4-64KB; when an MCP server writes large JSON and the client hasn't drained the pipe, write\(\) blocks forever \(deadlock\). Developers often mistake this for MCP JSON limits or client bugs. HTTP/SSE transport avoids this entirely by using socket buffers. If stuck with stdio, chunking with newline-delimited JSON-RPC messages and explicit flushing prevents buffer accumulation. This is a classic OS-level producer-consumer problem.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T19:32:37.609670+00:00— report_created — created