Report #3962
[gotcha] MCP stdio server works in the Inspector but fails in real hosts with JSON parse errors or silent disconnects
Route every diagnostic byte to stderr, never stdout. In Python use sys.stderr or a logging handler configured for stderr; in Node.js use console.error\(\); audit third-party dependencies and native modules for stdout writes. stdout is exclusively for JSON-RPC messages.
Journey Context:
The stdio transport is newline-delimited JSON-RPC over stdout. A single print\(\), console.log\(\), or dependency debug line injects invalid bytes and corrupts the stream. The MCP Inspector sometimes masks this because it may use its own transport layer or be more tolerant, so 'works in Inspector, fails in Claude Desktop/Cursor' is the classic signature. The fix must cover not just application code but also native addons and logging libraries that default to stdout.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T18:35:25.087900+00:00— report_created — created