Skip to content

Fix MCP stdio compliance; add initialize.instructions#6

Open
WhymustIhaveaname wants to merge 2 commits into
qpd-v:mainfrom
WhymustIhaveaname:main
Open

Fix MCP stdio compliance; add initialize.instructions#6
WhymustIhaveaname wants to merge 2 commits into
qpd-v:mainfrom
WhymustIhaveaname:main

Conversation

@WhymustIhaveaname

Copy link
Copy Markdown

This server currently fails the MCP init handshake under strict clients
like Claude Code CLI:

  • console.log leaks non-JSON into stdout, so I switched to console.error.
  • notifications/initialized has no id, but the default branch in
    handleRequest still replies with -32601; the client sees an orphan
    response and drops the connection. Now we skip any JSON-RPC message
    without an id.
  • Also populated the optional initialize.instructions field.

WhymustIhaveaname and others added 2 commits April 20, 2026 15:53
Two independent protocol bugs prevented Claude Code (and likely any
strict MCP host) from keeping the connection alive:

1. All log output went through console.log, which writes to stdout.
   The MCP stdio transport requires stdout to contain only JSON-RPC
   messages, so these log lines corrupted the channel. Every log call
   now goes through console.error (stderr).

2. JSON-RPC notifications such as `notifications/initialized` have no
   `id` field and must not receive a response. The default switch case
   replied with a "Method not found" error, which the client treated
   as an orphan response and dropped the connection. Notifications are
   now detected and ignored at the top of handleRequest.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Populate the optional `instructions` field in the initialize response so
that MCP clients can surface a one-line description of what this server
is for, without needing to discover and load every tool first.

Co-Bungled-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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