[azsdk-cli] Log to MCP clients over json-rpc instead of stdout#13475
Merged
benbp merged 6 commits intoAzure:mainfrom Jan 13, 2026
Merged
[azsdk-cli] Log to MCP clients over json-rpc instead of stdout#13475benbp merged 6 commits intoAzure:mainfrom
benbp merged 6 commits intoAzure:mainfrom
Conversation
294bf72 to
eb46983
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces MCP (Model Context Protocol) compatible logging infrastructure to the azsdk-cli tool. The changes enable proper logging when running in MCP server mode by registering custom loggers that route log messages through the MCP protocol instead of standard console output.
Key changes:
- Added new MCP logging infrastructure with context accessor, logger provider, and hosted service
- Integrated MCP context accessor into the tool instrumentation layer
- Modified service registration to conditionally use MCP-specific output helpers when in MCP mode
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| McpLogging.cs | Core MCP logging infrastructure including context accessor, logger provider, and raw output helper |
| McpLoggingHostedService.cs | Hosted service to initialize and manage MCP server context lifecycle |
| McpLoggingExtensions.cs | Extension method to configure MCP logging services |
| InstrumentedTool.cs | Added MCP server context accessor injection and initialization in tool invocation |
| ServiceRegistrations.cs | Conditional registration of MCP raw output helper and context accessor based on output mode |
| Program.cs | Logging configuration changes for MCP mode with console provider filtering and MCP logging setup |
af1ead6 to
e952fe7
Compare
6bcc186 to
3e91233
Compare
samvaity
approved these changes
Jan 9, 2026
Member
Member
Author
|
Added a couple updates:
|
566a83e to
9274090
Compare
samvaity
reviewed
Jan 9, 2026
samvaity
approved these changes
Jan 9, 2026
794e8ea to
d5b93ef
Compare
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.
resolves #11804
fixes #13422
This PR leverages the MCP logging utility and MCP SDK logging to route output from components back to the MCP client via json-rpc. Previously we were sending back all server log messages over stderr to avoid the misleading
failed to parse messagelog prefix from MCP clients, but it was still confusing because all logs would show up as[server stderr]. With this update logs will show up in a normal format prefixed by the category name.Aside from visual cleanup, the intent of this change is to also give some feedback to the user when there are long-running process operations going on. The internal process helper forwards stdout by default, so with this change that output now gets sent via MCP logging. In the future we could also consider building in first class support for the MCP progress utility, but I think to start this will be sufficient.
Example mcp client logging output when running an external process: