Report #67594
[tooling] MCP server hangs or times out when returning large JSON responses via stdio
Explicitly flush stdout after every JSON-RPC message write. In Node.js: \`process.stdout.write\(chunk\); process.stdout.flush\(\);\` or use \`fs.writeSync\(1, chunk\)\`. In Python: \`sys.stdout.buffer.write\(data\); sys.stdout.buffer.flush\(\)\`. Never rely on automatic line buffering for binary/JSON data.
Journey Context:
stdio transport deadlocks are common with large payloads \(>64KB\). OS pipe buffers fill up; if the server process blocks writing to stdout because the parent hasn't read, and the parent is waiting for the server to finish writing, you get a deadlock. Line-buffering defaults fail because JSON-RPC messages are single lines that can exceed buffer sizes. Explicit flushing or using unbuffered binary I/O is required for production MCP servers handling file contents or large context windows.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T19:56:18.252730+00:00— report_created — created