Skip to content

Conversation

@benbp
Copy link
Member

@benbp benbp commented Jan 6, 2026

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 message log 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:

2026-01-08 16:00:49.331 [info] ModelContextProtocol.Server.McpServer: Server (azsdk 0.5.11.0), Client (Visual Studio Code 1.106.3) method 'tools/call' request handler called.
2026-01-08 16:00:49.337 [info] Azure.Sdk.Tools.Cli.Tools.Verify.VerifySetupTool: Checking requirement: Node.js >= 22.16.0
2026-01-08 16:00:49.338 [info] Azure.Sdk.Tools.Cli.Helpers.ProcessHelper: Running command [node --version] in /home/ben/ai/projects/mcp-progress/tools/azsdk-cli/Azure.Sdk.Tools.Cli
2026-01-08 16:00:49.340 [info] Azure.Sdk.Tools.Cli.Helpers.McpRawOutputHelper: --------------------------------------------------------------------------------
2026-01-08 16:00:49.342 [info] Azure.Sdk.Tools.Cli.Tools.Verify.VerifySetupTool: Checking requirement: tsp-client >= 0.24.0
2026-01-08 16:00:49.342 [info] Azure.Sdk.Tools.Cli.Helpers.ProcessHelper: Running command [tsp-client --version] in /home/ben/ai/projects/mcp-progress/tools/azsdk-cli/Azure.Sdk.Tools.Cli
2026-01-08 16:00:49.375 [error] Azure.Sdk.Tools.Cli.Tools.Verify.VerifySetupTool: Command tsp-client --version failed to execute.

Instructions: cd eng/common/tsp-client, npm ci

@github-actions github-actions bot added the azsdk-cli Issues related to Azure/azure-sdk-tools::tools/azsdk-cli label Jan 6, 2026
@benbp benbp force-pushed the benbp/mcp-progress branch 3 times, most recently from 294bf72 to eb46983 Compare January 6, 2026 21:04
@benbp benbp added the Central-EngSys This issue is owned by the Engineering System team. label Jan 6, 2026
@benbp benbp moved this from 🤔 Triage to 🔬 Dev in PR in Azure SDK EngSys 📆🎇 Jan 6, 2026
@benbp benbp marked this pull request as ready for review January 6, 2026 22:05
Copilot AI review requested due to automatic review settings January 6, 2026 22:05
@benbp benbp requested a review from a team as a code owner January 6, 2026 22:05
@benbp benbp self-assigned this Jan 6, 2026
@benbp benbp marked this pull request as draft January 6, 2026 22:06
Copy link
Contributor

Copilot AI left a 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

@benbp benbp force-pushed the benbp/mcp-progress branch from af1ead6 to e952fe7 Compare January 8, 2026 21:14
@benbp benbp changed the title [azsdk-cli] Register mcp compatible logger [azsdk-cli] Log to MCP clients over json-rpc instead of stdout Jan 8, 2026
@benbp benbp force-pushed the benbp/mcp-progress branch 2 times, most recently from e45a38e to 6bcc186 Compare January 8, 2026 21:37
@benbp benbp force-pushed the benbp/mcp-progress branch from 6bcc186 to 3e91233 Compare January 8, 2026 21:37
@benbp benbp marked this pull request as ready for review January 8, 2026 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

azsdk-cli Issues related to Azure/azure-sdk-tools::tools/azsdk-cli Central-EngSys This issue is owned by the Engineering System team.

Projects

Status: 🔬 Dev in PR

Development

Successfully merging this pull request may close these issues.

[azsdk-cli] Support MCP logging/notifications for ILogger

1 participant