-
Notifications
You must be signed in to change notification settings - Fork 227
[azsdk-cli] Log to MCP clients over json-rpc instead of stdout #13475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
294bf72 to
eb46983
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
e45a38e to
6bcc186
Compare
6bcc186 to
3e91233
Compare
resolves #11804
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 verify setup: