Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion internal/wslogging/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,13 +449,20 @@ func (h *Handler) connect(wsURL, token string) (*websocket.Conn, error) {
// 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.

func logDiagnostic(w io.Writer, format string, args ...any) {
message := fmt.Sprintf(format, args...)
// trim trailing newline if present (we'll add it back after JSON)
message = strings.TrimSuffix(message, "\n")

// 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.

}

entry := map[string]any{
"level": "ERROR",
"level": level,
"msg": message,
"source": "wslogging",
"time": time.Now().UTC().Format(time.RFC3339Nano),
Expand Down