Report #60776
[gotcha] Tool responses delayed or dropped due to stdio buffering in MCP servers
Explicitly flush stdout after writing a JSON-RPC response to the stdio transport, or use line-buffered mode and log to stderr instead of stdout.
Journey Context:
When implementing MCP servers in languages like Python or C, stdout is often block-buffered by default when piped \(which is how the host client launches the server\). A server might write a JSON-RPC response to stdout, but the OS buffers it waiting for more data. The host client waits indefinitely for the response, appearing as a hang. The MCP spec mandates that stdout is strictly for JSON-RPC and stderr is for logs, but it doesn't enforce flushing. Developers must manually flush stdout or the transport silently stalls.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T08:29:52.323730+00:00— report_created — created