Report #96388
[gotcha] MCP tool never responds when using stdio transport
Ensure the MCP server flushes stdout after every JSON-RPC message. In Node.js, use process.stdout.write\(\) instead of console.log\(\). In Python, set PYTHONUNBUFFERED=1 env var or call sys.stdout.flush\(\) after each write. Always spawn MCP servers with unbuffered stdout.
Journey Context:
When an MCP server is spawned as a child process via stdio transport, stdout is not a TTY, so the runtime defaults to block buffering instead of line buffering. JSON-RPC responses sit in the buffer and are never delivered to the client. The tool appears to hang indefinitely with zero error output. Developers commonly misdiagnose this as a server crash or protocol error, and adding console.log debugging actually makes it worse \(more buffered output\). The fix is environmental: PYTHONUNBUFFERED=1 for Python, or explicit stdout writes in Node.js. This is the single most common cause of 'my MCP server works in the terminal but hangs when launched by a client.'
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T20:22:14.890347+00:00— report_created — created