Skip to content

Conversation

@thearyanahmed
Copy link
Contributor

No description provided.

// logDiagnostic writes a diagnostic message to the specified writer.
// This is used for logging infrastructure issues (not application logs).
// Messages are written as JSON to maintain consistency with application logs.
// The log level is determined by the writer: stderr produces error level, stdout produces info level.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be debug by default since they will potentially be very noisy.

// determine log level based on the writer
level := "info"
if w == os.Stderr {
level = "error"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this can be dropped.

When using stdio transport, log messages are routed to the stdout stream for JSON rpc calls between the client and the server. In order to not interfere with with client and server communication, the mcp protocol states that debug error messages should be routed to the stderr stream. So using stderr as transport does not equate to an error level log. We shouldn't mix those two.

Suggested change
level = "error"
level = "error"

https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#stdio

The server MAY write UTF-8 strings to its standard error (stderr) for logging purposes. Clients MAY capture, forward, or ignore this logging.

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