Skip to content

fix(logging): route diagnostic logs to stderr to prevent stdio transport corruption (#15) - #17

Open
Lesnak1 wants to merge 1 commit into
base:masterfrom
Lesnak1:fix/mcp-stdio-logging-stderr
Open

fix(logging): route diagnostic logs to stderr to prevent stdio transport corruption (#15)#17
Lesnak1 wants to merge 1 commit into
base:masterfrom
Lesnak1:fix/mcp-stdio-logging-stderr

Conversation

@Lesnak1

@Lesnak1 Lesnak1 commented Aug 17, 2026

Copy link
Copy Markdown

Summary

Fixes #15.

In the Model Context Protocol (MCP) stdio transport specification, stdout is strictly reserved for JSON-RPC protocol message frames ({"jsonrpc":"2.0",...}).

Previously, sidebar.ts and tools.ts logged diagnostic messages using console.log() to stdout (including dumping raw fetched markdown sidebar content). When MCP clients (Claude Desktop, Cursor, Zed, Goose, Antigravity) parse stdout, non-JSON text intermingled with JSON-RPC payloads corrupts the message stream and causes JSON parsing crashes.

Changes

  • sidebar.ts: Replaced console.log() with console.error() for diagnostic logs and removed the raw markdown dump (console.log(sidebarContent)) to keep stdout completely clean.
  • tools.ts: Replaced all console.log() calls with console.error() across the getGuide workflow.

Verification

  • Verified that all diagnostic output routes to stderr, preserving valid JSON-RPC framing on stdout.
  • Tested tool execution with MCP clients without protocol parse errors.

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.

bug: stdout logging can corrupt MCP stdio transport

1 participant