claude-code - 💡(How to fix) Fix [DOCS] MCP stdio server docs missing stdout/stderr protocol guidance [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#48866Fetched 2026-04-16 06:48:48
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×4
RAW_BUFFERClick to expand / collapse

Documentation Type

Missing documentation (feature not documented)

Documentation Location

https://code.claude.com/docs/en/mcp

Section/Topic

Option 3: Add a local stdio server in the MCP docs, plus the stdio servers and troubleshooting guidance in the Agent SDK MCP docs.

Current Documentation

The MCP docs currently say:

Option 3: Add a local stdio server

Stdio servers run as local processes on your machine. They're ideal for tools that need direct system access or custom scripts.

The Agent SDK MCP docs currently say:

stdio servers

Local processes that communicate via stdin/stdout. Use this for MCP servers you run on the same machine:

The Agent SDK troubleshooting section lists missing environment variables, missing installs, invalid connection strings, network issues, and slow initialization, but it does not explain that stdio server stdout must stay reserved for MCP protocol traffic or that diagnostic output should go to stderr.

What's Wrong or Missing?

Claude Code v2.1.110 fixed this changelog item:

Fixed stdio MCP servers that print stray non-JSON lines to stdout being disconnected on the first stray line (regression in 2.1.105)

That fix exposes an important setup/troubleshooting detail that the docs still do not explain: for stdio MCP servers, stdout is the protocol channel. If a custom server, wrapper script, shell startup, or dependency prints banners/logging/non-JSON text to stdout, the connection can fail or behave unpredictably.

The current docs tell users how to add local stdio servers, but they do not tell them:

  1. stdout should be reserved for MCP JSON-RPC traffic
  2. logs/debug output should go to stderr instead of stdout
  3. stray stdout output is a concrete thing to check when a stdio server fails to connect or disconnects unexpectedly

Suggested Improvement

Add a short note in the local stdio server sections explaining the transport expectation explicitly, for example:

Important: For stdio MCP servers, stdout is reserved for MCP protocol messages. Do not print banners, logs, or other non-JSON text to stdout. Send diagnostics to stderr instead.

Also add a troubleshooting bullet such as:

If a local stdio server fails to connect, disconnects unexpectedly, or shows Connection closed, check whether the server or any wrapper script is writing stray output to stdout during startup or while running.

This should appear in both the general MCP docs and the Agent SDK MCP troubleshooting section so users configuring custom/local servers get the same guidance in both places.

Impact

Medium - Makes feature difficult to understand

Additional Context

Affected Pages:

PageContext
https://code.claude.com/docs/en/mcpUser-facing setup docs for adding local stdio MCP servers
https://code.claude.com/docs/en/agent-sdk/mcpAgent SDK docs for configuring stdio MCP servers and troubleshooting failed connections

Total scope: 2 pages affected

Source: Changelog v2.1.110

Exact changelog entry: Fixed stdio MCP servers that print stray non-JSON lines to stdout being disconnected on the first stray line (regression in 2.1.105)

extent analysis

TL;DR

Update the documentation for local stdio servers to explicitly state that stdout should be reserved for MCP protocol messages and that diagnostics should be sent to stderr.

Guidance

  • Add a note to the local stdio server sections in both the general MCP docs and the Agent SDK MCP troubleshooting section to explain the transport expectation.
  • Include a troubleshooting bullet point to check for stray output to stdout when a local stdio server fails to connect or disconnects unexpectedly.
  • Verify that the updated documentation clearly explains the importance of reserving stdout for MCP protocol messages and sending diagnostics to stderr.
  • Review the affected pages (https://code.claude.com/docs/en/mcp and https://code.claude.com/docs/en/agent-sdk/mcp) to ensure the updates are consistent and accurate.

Example

A possible example of the updated documentation could be:

Important: For stdio MCP servers, stdout is reserved for MCP protocol messages. Do not print banners, logs, or other non-JSON text to stdout. Send diagnostics to stderr instead. If a local stdio server fails to connect, disconnects unexpectedly, or shows Connection closed, check whether the server or any wrapper script is writing stray output to stdout during startup or while running.

Notes

The updates should be made to both the general MCP docs and the Agent SDK MCP troubleshooting section to ensure consistency and provide clear guidance to users configuring custom/local servers.

Recommendation

Apply the suggested improvement to update the documentation, as it will provide clear guidance to users and help prevent issues with local stdio servers.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [DOCS] MCP stdio server docs missing stdout/stderr protocol guidance [1 participants]