fix(serve-mcp): TelemetryRecorder migration, McpToolCallLogger, stdio tracing#67
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
JUL → TelemetryRecorder.
McpServerdropsjava.util.loggingentirely and routes all server-level output through aTelemetryRecorderinjected viaBuilder.recorder(...).Stdout pollution fix. The default recorder previously split output between
System.out(info/diagnostic) andSystem.err(warn/error). In stdio modeSystem.outis the NDJSON protocol channel, so info and diagnostic output silently corrupted the stream. The default is nowPrintStreamTelemetryRecorder.of(..., System.err, System.err). A new test reproduces the bug by redirectingSystem.outbefore building the server and asserting that every byte on the protocol stream is valid JSON.Request/response tracing.
dispatch()records a diagnostic before and after every handled method, giving stdio and HTTP callers a trace of what the server saw and responded to.Clean EOF vs broken pipe.
stdioLooppreviously swallowed allIOExceptions silently. It now records an info event on clean EOF and a warn event (with the exception message) on any unexpectedIOException.McpToolCallLogger. NewSubscriber<ToolCallEvent>that logs STARTED at diagnostic level, SUCCEEDED at info (or warn when the call exceeds the slow-call threshold, default 5 s), and FAILED at warn with the thrown exception. Attach manually viamcpServer.toolCallEvents().subscribe(McpToolCallLogger.of(recorder))or enable at build time viaBuilder.logToolCalls(), which wires the logger to the server's own recorder automatically.