Skip to content

[Bug]: Windows stdio mode outputs formatted logs to stdout, breaking MCP JSON-RPC protocol #264

@Igor-codi

Description

@Igor-codi

What happened?

MCPM Version: 2.8.1
Platform: Windows 11
Installation Method: pipx
Affected Commands: mcpm run <server>, mcpm profile run <profile>

Summary

When running MCPM servers in stdio mode on Windows, formatted log messages with timestamps and box-drawing characters are written to stdout, corrupting the JSON-RPC communication stream and making the servers incompatible with MCP clients like Claude Desktop.

Expected Behavior

In stdio mode, only JSON-RPC messages should be written to stdout. All logging, status messages, and formatted output should go to stderr to maintain clean stdio communication.

Actual Behavior

MCPM writes formatted log messages to stdout, mixing them with JSON-RPC messages:

[09/15/25 00:30:17] INFO     mcpm.commands.run: Starting server 'time' over stdio
{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2024-11-05"...}}
[09/15/25 00:30:52] WARNING  root: Failed to validate request: Received request before initialization was complete
{"jsonrpc":"2.0","id":2,"error":{"code":-32602,"message":"Invalid request parameters","data":""}}

This causes MCP clients to fail with JSON parsing errors:

SyntaxError: Unexpected token '┌', "┌─────────"... is not valid JSON
SyntaxError: Unexpected token '│', "│ in _run_"... is not valid JSON

Reproduction Steps

Minimal Reproduction

  1. Install MCPM on Windows via pipx

  2. Install a server: mcpm install time

  3. Run in stdio mode: mcpm run time

  4. Send MCP JSON-RPC initialize message:

    {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{"roots":{"listChanged":true},"sampling":{}},"clientInfo":{"name":"test-client","version":"1.0.0"}}}

Result: Log messages pollute stdout, breaking JSON parsing

MCP Inspector Integration (mcpm inspect time)

  1. Install and run the time server with MCP Inspector:

    mcpm install time
    mcpm inspect time
  2. The MCP Inspector launches and tries to connect to mcpm run time over stdio

Result: MCP Inspector logs show continuous JSON parsing errors because MCPM outputs formatted logs to stdout:

Error from MCP server: SyntaxError: Unexpected token '┌', "┌─────────"... is not valid JSON
Error from MCP server: SyntaxError: Unexpected token '│', "│ in _run_"... is not valid JSON
Error from MCP server: SyntaxError: Unexpected token '│', "│         "... is not valid JSON
Error from MCP server: SyntaxError: Unexpected token '│', "│ in <modu"... is not valid JSON

Environment Details

  • OS: Windows 11
  • Shell: PowerShell 5.1.26100.6584
  • Python: 3.13.7 (Microsoft Store)
  • MCPM Installation: pipx 1.7.1
  • MCPM Path: C:\Users\username\.local\bin\mcpm.exe

Analysis

The issue appears to be Windows-specific stdio handling. The same servers work correctly on Ubuntu/Linux where logs are properly separated from JSON-RPC output.

Evidence from MCP Inspector

When using mcpm inspect time, the MCP Inspector shows extensive JSON parsing errors:

Error from MCP server: SyntaxError: Unexpected token '┌', "┌─────────"... is not valid JSON
Error from MCP server: SyntaxError: Unexpected token '│', "│ in _run_"... is not valid JSON
Error from MCP server: SyntaxError: Unexpected token '│', "│         "... is not valid JSON

Working Workarounds

  1. HTTP Mode: mcpm run time --http works perfectly (logs go to stderr, JSON-RPC over HTTP)
  2. SSE Mode: mcpm run time --sse works perfectly
  3. Ubuntu/WSL: stdio mode works correctly on Linux

Impact

This bug makes MCPM unusable with stdio-based MCP clients on Windows, including:

  • MCPM's own MCP Inspector (mcpm inspect)
  • Claude Desktop
  • Cursor
  • VSCode MCP extensions
  • Custom MCP client implementations

The issue is immediately reproducible using MCPM's built-in tooling (mcpm inspect time), making it impossible to debug or test servers on Windows. Users must resort to HTTP/SSE modes or abandon MCPM entirely for Windows stdio scenarios.

Suggested Fix

Ensure all logging output goes to stderr instead of stdout in stdio mode. The stdio transport should maintain a clean stdout channel exclusively for JSON-RPC messages.

Potential implementation:

  • Redirect all INFO, WARNING, ERROR logs to stderr
  • Ensure formatted output (box-drawing, progress bars) goes to stderr
  • Keep only JSON-RPC protocol messages on stdout

Additional Context

Log Examples

What currently goes to stdout (❌):

[09/15/25 00:30:17] INFO     mcpm.commands.run: Starting server 'time' over stdio
[09/15/25 00:30:52] WARNING  root: Failed to validate request: Received request before initialization was complete
┌─────────────────────────────┐
│ MCPM Inspector              │
│ Inspecting server: time     │
└─────────────────────────────┘

What should go to stdout (✅):

{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2024-11-05","capabilities":{"experimental":{}},"serverInfo":{"name":"mcpm-run-time","version":"1.14.0"}}}
{"jsonrpc":"2.0","id":2,"result":{"tools":[{"name":"get_current_time","description":"Get current time in a specific timezones"}]}}

Comparison with Working Platforms

  • Ubuntu 22.04: stdio mode works correctly, logs properly separated
  • macOS: (not tested, but likely works based on Unix stdio behavior)
  • Windows with HTTP mode: Works perfectly, demonstrates the logging separation is possible

This suggests the issue is specifically with Windows stdio handling in the MCPM codebase.


Priority: High - Breaks Windows compatibility with major MCP clients
Component: stdio transport, Windows platform support
Labels: bug, windows, stdio, logging

What did you expect?

In stdio mode, only JSON-RPC messages should be written to stdout. All logging, status messages, and formatted output should go to stderr to maintain clean stdio communication.

MCPM Version

2.8.1

OS

Windows

Logs

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions