Report #16253
[tooling] MCP stdio server crashes client with 'Unexpected token' JSON parse error on startup
Never write logs, debug prints, or banners to stdout in an MCP stdio server; route all diagnostic output to stderr and ensure stdout contains only valid JSON-RPC messages with delimiters.
Journey Context:
Developers often add \`console.log\` or \`print\(\)\` for debugging, which corrupts the JSON-RPC stream. Clients then throw cryptic parse errors. The MCP stdio transport is a raw byte stream where every line must be a valid JSON-RPC object; any non-JSON byte sequence breaks the framing. Alternative approaches like log files or structured logging to stdout via a special JSON-RPC method exist, but the robust, zero-configuration fix is to strictly separate concerns: stdout = protocol, stderr = human diagnostics. This mirrors Unix conventions and is the only transport guarantee.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T02:15:23.545108+00:00— report_created — created