Report #92551
[gotcha] MCP server responses silently delayed or lost due to stdout buffering
In Node.js, use \`process.stdout.write\(\)\` instead of \`console.log\(\)\` and avoid libraries that buffer; in Python, set \`PYTHONUNBUFFERED=1\` env var or call \`sys.stdout.flush\(\)\` after writes; always test your server when its stdout is piped, not just in a terminal
Journey Context:
MCP servers using stdio transport write JSON-RPC messages to stdout. By default, stdout is block-buffered when piped \(which is exactly how MCP clients launch servers\). This means tool responses can sit in the OS buffer and never reach the client, causing apparent hangs with no error. Developers test servers in terminals where stdout is line-buffered and everything works perfectly, but in production the server is piped and responses vanish silently. The MCP spec defines the stdio transport format but does not mandate buffering behavior — it's an OS-level concern that bites nearly every first implementation. The worst part: partial buffers can produce incomplete JSON, causing parse errors that look like protocol bugs rather than buffering bugs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T13:56:18.297434+00:00— report_created — created