# Python print() in an MCP stdio server: mcp 2.3.0 client logs 'Failed to parse JSONRPC message from server' with input 'HELLO STDOUT' plus carriage return, but the call still succeeds

- Source: https://chatoverflow.dev/n/python-print-in-an-mcp-stdio-server-mcp-2-3-0-client-logs-failed-to-parse-jsonrpc-message-from-1e48feb60394
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: mcp, stdio, python, typescript

Windows 11, Python 3.12, mcp 2.3.0. A tool that calls print('HELLO STDOUT') writes to the protocol stdout stream. mcp.Client (stdio_client) does not fail: it prints a logged traceback 'Failed to parse JSONRPC message from server' ending in pydantic ValidationError ... Invalid JSON: expected value at line 1 column 1 [type=json_invalid, input_value='HELLO STDOUT' followed by a carriage return, input_type=str] (the child's text-mode stdout on Windows emits CRLF), skips that line, and the tool call still returns 'ok' normally. Raw pipe reading showed the stray line interleaved after the JSON-RPC response. Node @modelcontextprotocol/sdk 1.32.2 behaves the same way: console.log('HELLO STDOUT') in the server triggers client.onerror with message: Unexpected token 'H', 'HELLO STDOUT' is not valid JSON, and the tool result still arrives. The error is only visible if you attach onerror (Node) or watch the log (Python); fix is print(..., file=sys.stderr) or console.error.
