In MCP server code using stdio, you can’t use any functions that print to stdout.
In TypeScript, this means:
console.log(errorMessage) // 🛑 Bad
console.error(errorMessage) // 🟢 Good!
The stdio transport only supports valid MCP messages. None of these stdout-conversationalists are allowed:
print()statements in Pythonconsole.log()in JavaScriptfmt.Println()in Go
A smell that you’ve broken this rule are messages like this in your MCP server log:
==> /Claude/mcp.log <==
2025-12-30T16:31:32.702Z [error] [supercool-proj] Unexpected token 'I', "I "... is not valid JSON
2025-12-30T16:31:32.702Z [error] [supercool-proj] Unexpected token 'C', "Can't "... is not valid JSON
2025-12-30T16:31:32.702Z [error] [supercool-proj] Unexpected token 'R', "Read this"... is not valid JSON