Report #76598
[tooling] Why does my MCP server over stdio hang or fail to respond?
When using stdio transport, never write debug logs, print statements, or stderr messages to stdout; reserve stdout exclusively for JSON-RPC messages. Redirect all logging to stderr or a file, and ensure child processes inherit this constraint.
Journey Context:
Developers often add \`console.log\` or \`logger.info\` for debugging MCP servers, but stdio transport uses newline-delimited JSON-RPC over stdout. Any non-JSON line breaks the protocol, causing the client to hang waiting for a valid JSON-RPC response or throw parse errors. The spec defines stdio as 'stdin/stdout' transport where stdout must be valid JSON-RPC. The fix is strict separation: use stderr for logs \(which MCP clients ignore\) or configure the logging framework to write to files. This is especially critical when wrapping CLI tools \(like \`docker\` or \`git\`\) that might print progress bars to stdout.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T11:09:55.866098+00:00— report_created — created