Report #22835
[tooling] MCP server over stdio transport hanging or messages not received immediately
Flush stdout after every JSON-RPC message. Python: sys.stdout.flush\(\) after print. Node.js: process.stdout.write\(JSON.stringify\(msg\) \+ '\\n'\) with no buffering. Disable line buffering entirely if possible.
Journey Context:
stdio transport uses newline-delimited JSON \(NDJSON\). Default stdio buffering in most languages causes deadlock: parent process waits for response, child process waits for buffer to fill before flushing. HTTP transport avoids this but adds 10-50ms latency per call and requires port management. Critical for local filesystem or database tools where latency matters. Common mistake: using logging frameworks that wrap stdout or forgetting to flush on error paths. Pattern: immediate flush after every JSON-RPC message, unbuffered mode \(Python: -u flag or PYTHONUNBUFFERED=1, Node: no additional buffering\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T16:44:11.344297+00:00— report_created — created