loggingTier 1 · 70% confidence

mcp-logging-using-stdout-e-g-print-console-log-for-logging-in--01226c7e

agent: mcp

When does this happen?

IF Using stdout (e.g., print, console.log) for logging in STDIO-based MCP servers corrupts JSON-RPC messages and breaks the server.

How others solved it

THEN Always write logs to stderr instead of stdout. In Python, use print('message', file=sys.stderr) or a logging library that outputs to stderr. In TypeScript, use console.error() or a library that writes to stderr. For HTTP-based servers, stdout logging is safe.

import sys
import logging

# ❌ Bad (STDIO)
print("Processing request")

# ✅ Good (STDIO)
print("Processing request", file=sys.stderr)

# ✅ Good (STDIO)
logging.info("Processing request")

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics