-
Notifications
You must be signed in to change notification settings - Fork 289
Add detailed logs from the MCP Server #778
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
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 enables detailed MCP Server logging for live test visibility by adding comprehensive logging configuration options. The changes allow tests to capture logs through both verbose stderr output and file-based logging without requiring additional debugging tools.
Key changes:
- Added configurable logging levels and verbose mode through command line options and environment variables
- Implemented file-based logging with placeholder support for timestamps and process IDs
- Enhanced logging configuration for both STDIO and HTTP server modes
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| SimpleFileLoggerProvider.cs | New lightweight file logger implementation for structured log output |
| ServiceStartOptions.cs | Added logging configuration properties (LogLevel, Verbose, LogFile) |
| ServiceOptionDefinitions.cs | Defined new command line options for logging controls |
| ServiceStartCommand.cs | Integrated logging options with environment variable support and enhanced logging setup |
Comments suppressed due to low confidence (1)
core/Azure.Mcp.Core/src/Services/Logging/SimpleFileLoggerProvider.cs:1
- The Verbose option should be of type Option instead of Option<string?> since it represents a boolean flag. The DefaultValueFactory should return a boolean value false instead of the string "false".
// Copyright (c) Microsoft Corporation.
core/Azure.Mcp.Core/src/Areas/Server/Commands/ServiceStartCommand.cs
Outdated
Show resolved
Hide resolved
core/Azure.Mcp.Core/src/Services/Logging/SimpleFileLoggerProvider.cs
Outdated
Show resolved
Hide resolved
84b2be2 to
dffbee1
Compare
| { | ||
| logging.ClearProviders(); | ||
| logging.ConfigureOpenTelemetryLogger(); | ||
| logging.AddEventSourceLogger(); |
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.
We can have a conversation offline if it is easier but I was hoping that we wouldn't have to add these switches.
Using a custom ILogger, we can leverage existing infrastructure to output logs. The user experience here is to do azmcp.exe server start --log-level debug. But this only applies to the logger we wrote, the settings won't also apply to the "EventSourceLogger" or any other ILogger.
I was hoping that an end user would be able to do something like:
set Logging__LogLevel__Default=Debug
./azmcp.exe server startAnd this log level would apply to your new logger, and also the EventSourceLogger, any other Console logger, possibly a file logger if there is one.
Or they can use the same configuration system to be more granular about their logging. There's a bigger example here: Configure Logging
The bonus would be that they wouldn't have to learn something new about our logging because it uses the same configuration as other .NET loggers.
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.
Or if you used the [ProviderAlias("AzureMcpDebugLogger")] or something, they could configure our logger via:
set Logging__AzureMcpDebugLogger__LogLevel=Debug
What does this PR do?
Adds a unified, configurable logging system to help users and developers diagnose issues, inspect MCP protocol activity, and debug tool execution without requiring complex tools like PerfView or dotnet-trace.
This enables clear, actionable visibility into MCP Server behavior through configurable console and file logging.
Key Changes
Enhanced ServiceStartCommand – Added ASP.NET Core–compliant logging configuration with CLI, environment, and appsettings hierarchy (CLI → Env → Config → Default).
Custom FileLoggerProvider – Added file logging with {timestamp} and {pid} placeholders and automatic directory creation.
New CLI options:
Routes logs to STDERR to keep MCP protocol output clean.
Updated live-test.yml with environment variables for automated logging
GitHub issue number?
#142
Pre-merge Checklist
servers/Azure.Mcp.Server/CHANGELOG.mdand/orservers/Fabric.Mcp.Server/CHANGELOG.mdfor product changes (features, bug fixes, UI/UX, updated dependencies)