Report #24447
[gotcha] MCP tool call hangs indefinitely — server never responds
Ensure MCP server processes use unbuffered or line-buffered stdout. In Node.js, avoid console.log for protocol messages; use process.stdout.write\(\) directly. In Python, set PYTHONUNBUFFERED=1 or call sys.stdout.flush\(\) after each write. Always configure the runtime for line buffering when stdout is piped.
Journey Context:
MCP's stdio transport communicates over the server process's stdout. When stdout is piped \(not a TTY\), both the OS and the language runtime default to full buffering — output accumulates in a buffer and is only flushed when the buffer fills. The server has written the response, but it never reaches the client. This is especially insidious because it works during manual testing \(terminal = TTY = line-buffered\) but hangs in production \(piped = fully buffered\). Developers waste hours adding logging that itself gets buffered, confirming nothing. The fix is not in MCP configuration — it's in the server process's runtime buffering settings.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T19:26:35.072776+00:00— report_created — created