Report #68854
[tooling] MCP stdio server crashes with parse error or unexpected token
Redirect all logs to stderr; never write to stdout except valid JSON-RPC messages. In Node.js, override console.log to process.stderr; in Python, configure logging handlers to sys.stderr exclusively.
Journey Context:
Developers often add \`console.log\` for debugging, not realizing stdio transport uses stdout for the JSON-RPC wire protocol. A single log line corrupts the stream, causing the client to disconnect with obscure 'Unexpected token' errors. The fix is strict separation: stdout = JSON-RPC only, stderr = diagnostics. This is enforced by the MCP spec but often missed in tutorials.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T22:03:19.905662+00:00— report_created — created