Skip to content

Pin fmt layer writer to stderr#97

Merged
avelino merged 1 commit into
mainfrom
avelino/issue-96
May 19, 2026
Merged

Pin fmt layer writer to stderr#97
avelino merged 1 commit into
mainfrom
avelino/issue-96

Conversation

@avelino

@avelino avelino commented May 19, 2026

Copy link
Copy Markdown
Owner

tracing-subscriber's default writer is stdout, so logs were leaking into the JSON-RPC stream when mcp serve runs over stdio. The doc comment already promised stderr, so the code was lying about its own behavior.

Set with_writer(std::io::stderr) explicitly on both json and text branches.

fixed: #96

tracing-subscriber's default writer is stdout, so logs were leaking into the JSON-RPC stream when mcp serve runs over stdio. The doc comment already promised stderr, so the code was lying about its own behavior.

Set with_writer(`std::io::stderr`) explicitly on both json and text branches.

Signed-off-by: Avelino <31996+avelino@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 19, 2026 18:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes mcp’s tracing output stream selection so that structured logs no longer leak into stdout (and therefore into the JSON-RPC/stdout protocol stream when running over stdio). It makes the implementation match the existing doc comment that promised stderr for JSON logging.

Changes:

  • Pin tracing_subscriber::fmt layer output to stderr for MCP_LOG_FORMAT=json.
  • Pin tracing_subscriber::fmt layer output to stderr for the default/text branch as well.

@avelino avelino merged commit 2b72093 into main May 19, 2026
8 checks passed
@avelino avelino deleted the avelino/issue-96 branch May 19, 2026 19:47
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.

Tracing logs leak to stdout instead of stderr

2 participants