Skip to content

Fix: MCP stdio transport broken by non-JSON startup output on stdout - #63

Open
disq wants to merge 1 commit into
mainfrom
claude/mcp-server-stdout-pollution-600aea
Open

Fix: MCP stdio transport broken by non-JSON startup output on stdout#63
disq wants to merge 1 commit into
mainfrom
claude/mcp-server-stdout-pollution-600aea

Conversation

@disq

@disq disq commented Aug 19, 2026

Copy link
Copy Markdown

Issue

The Docker image writes non-JSON output to stdout on startup, so MCP clients on the stdio transport fail to parse it ("Unexpected token" errors in Claude Desktop). Two sources: npm start echoes the script command, and dotenv v17 prints its injection banner.

Solution

  • Dockerfile CMD runs npx tsx src/cli.ts directly, bypassing npm's echo. NPM_CONFIG_UPDATE_NOTIFIER=false silences the npx update notice.
  • dotenv.config() gets quiet: true.
  • README MCP Inspector example no longer uses npm start.

QA

  • Built the image, piped an MCP initialize request through docker run -i: stdout carries only the JSON-RPC response, stderr is empty.
  • Lint and type-check pass.

Run tsx directly instead of via npm start (npm echoes the script to
stdout), and pass quiet: true to dotenv so its injection banner is
suppressed. MCP clients require stdout to carry only JSON-RPC.
@disq
disq marked this pull request as ready for review August 19, 2026 13:11
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