Skip to content

Fix: Replace stdout logging with stderr to prevent MCP protocol errors#2

Open
2Cloud-S wants to merge 1 commit intoDerfirm:mainfrom
2Cloud-S:fix/stdout-logging-breaking-mcp-protocol
Open

Fix: Replace stdout logging with stderr to prevent MCP protocol errors#2
2Cloud-S wants to merge 1 commit intoDerfirm:mainfrom
2Cloud-S:fix/stdout-logging-breaking-mcp-protocol

Conversation

@2Cloud-S
Copy link
Copy Markdown

Console.log() and console.debug() write to stdout, which breaks the MCP JSON-RPC protocol that uses stdin/stdout for communication. This caused "Unexpected token" parsing errors when the client tried to parse debug messages as JSON-RPC responses.

Changes:

  • Replaced all console.log() calls with console.error()
  • Replaced all console.debug() calls with console.error()
  • Updated logDebug() method to use stderr

This ensures all diagnostic logging goes to stderr, keeping stdout clean for JSON-RPC protocol messages.

Fixes the following errors:

  • SyntaxError: Unexpected token 'D', "[DEBUG] Ope"... is not valid JSON
  • SyntaxError: Unexpected token 'S', "[SERVER] Us"... is not valid JSON

Console.log() and console.debug() write to stdout, which breaks the
MCP JSON-RPC protocol that uses stdin/stdout for communication. This
caused "Unexpected token" parsing errors when the client tried to parse
debug messages as JSON-RPC responses.

Changes:
- Replaced all console.log() calls with console.error()
- Replaced all console.debug() calls with console.error()
- Updated logDebug() method to use stderr

This ensures all diagnostic logging goes to stderr, keeping stdout
clean for JSON-RPC protocol messages.

Fixes the following errors:
- SyntaxError: Unexpected token 'D', "[DEBUG] Ope"... is not valid JSON
- SyntaxError: Unexpected token 'S', "[SERVER] Us"... is not valid JSON
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant