Skip to content

Conversation

cliffhall
Copy link
Member

@cliffhall cliffhall commented Aug 21, 2025

Description

Motivation and Context

A recent change to the server-everything reference server raised the point that notification/stderr is not a valid MCP message type. It was only added to the server because handling for it existed in the Inspector, added some time ago.

Clearly, handling for this message type needs to also be removed from the Inspector so as not to confuse developers who may come across it as I myself did, leading to my erroneously adding the periodic sending of notification/stderr messages from server-everything.

As far as I can tell, it only existed as a way to indicate that the message came from thestderr output of a STDIO server, so that it could be handled differently from other logging messages, placing the output prominently in the sidebar in red to indicate error. However, another recent issue highlights that this is not a valid approach, since all output, even innocuous server welcome messages must be sent via stderr in STDIO servers.

Therefore, I have removed the handling of this out-of-spec message type and am sending all stderr output to the client as MCP compliant logging messages. I attempt to set an appropriate logging level by inspecting the contents of the message and searching for levels. So if a STDIO server output the following line on stderr:

[info] The fetch tool was used.

...the following message would be sent to the client...

{
  "jsonrpc": "2.0",
  "method": "notifications/message",
  "params": {
    "level": "info",
    "logger": "stdio",
    "data": {
      "message": "[info] The fetch tool was used",
    },
  },
}

How Has This Been Tested?

Using an STDIO server that outputs a welcome message on stderr
Screenshot 2025-08-21 at 7 15 45 PM

Breaking Changes

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • [] I have added or updated documentation as needed

Additional context

… not a thing. See modelcontextprotocol/servers#2469

* Inspect the stderr output of STDIO servers and attempt to assign an appropriate RFC 5424 Syslog Protocol level before sending a leveled logging message to the client
… not a thing. See modelcontextprotocol/servers#2469

* Inspect the stderr output of STDIO servers and attempt to assign an appropriate RFC 5424 Syslog Protocol level before sending a leveled logging message to the client
@cliffhall cliffhall requested a review from olaservo August 21, 2025 22:51
@cliffhall cliffhall requested a review from evalstate August 21, 2025 22:56
@cliffhall cliffhall changed the title Stderr handling Handling of stderr on STDIO servers Aug 21, 2025
@cliffhall cliffhall changed the title Handling of stderr on STDIO servers Handling of stderr on STDIO servers Aug 21, 2025
Copy link
Member

@olaservo olaservo left a comment

Choose a reason for hiding this comment

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

Tested with everything-server and saw notifications logged but no noise in the sidebar:
notif1
notif2

@olaservo olaservo merged commit f22aa1f into modelcontextprotocol:main Aug 22, 2025
5 checks passed
@cliffhall cliffhall deleted the stderr-handling branch August 22, 2025 13:12
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.

2 participants