-
Notifications
You must be signed in to change notification settings - Fork 316
Add DangerouslyWriteSupportLogsToDir support #1305
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
| command.Options.Add(ServiceOptionDefinitions.DangerouslyDisableHttpIncomingAuth); | ||
| command.Options.Add(ServiceOptionDefinitions.InsecureDisableElicitation); | ||
| command.Options.Add(ServiceOptionDefinitions.OutgoingAuthStrategy); | ||
| command.Options.Add(ServiceOptionDefinitions.DangerouslyEnableSupportLoggingToFolder); |
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.
Usually Enable indicates a boolean. Since this takes a directory path, we should consider an alternate name.
Some suggestions:
--dangerously-write-support-logs-to-dir--unsafe-support-log-dir(also used in Azure Identity)--dangerously-log-to-dir
If we don't have to use "dangerously" prefix, then I am inclined to use the 2nd option.
| { | ||
| string? folderPath = commandResult.GetValueOrDefault<string?>(ServiceOptionDefinitions.DangerouslyEnableSupportLoggingToFolder.Name); | ||
|
|
||
| if (string.IsNullOrEmpty(folderPath)) |
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.
Should we check for only null here? Empty string is invalid.
| } | ||
|
|
||
| // Validate the folder path is not empty or whitespace | ||
| if (string.IsNullOrWhiteSpace(folderPath)) |
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.
Should we validate that the folder path is actually valid and not just check for whitespace?
| /// <param name="options">The server configuration options.</param> | ||
| private static void ConfigureSupportLogging(ILoggingBuilder logging, ServiceStartOptions options) | ||
| { | ||
| if (string.IsNullOrWhiteSpace(options.SupportLoggingFolder)) |
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.
Why is this check required as the validation is already done to ensure it is not null or empty?
| logging.AddConsole(consoleOptions => | ||
| { | ||
| consoleOptions.LogToStandardErrorThreshold = LogLevel.Debug; | ||
| consoleOptions.FormatterName = Microsoft.Extensions.Logging.Console.ConsoleFormatterNames.Simple; | ||
| }); | ||
| logging.AddSimpleConsole(simple => | ||
| { | ||
| simple.ColorBehavior = Microsoft.Extensions.Logging.Console.LoggerColorBehavior.Disabled; | ||
| simple.IncludeScopes = true; | ||
| simple.SingleLine = true; | ||
| simple.TimestampFormat = "[yyyy-MM-dd HH:mm:ss.fff] "; | ||
| }); |
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.
Why is console logging also enabled when we are logging to a file?
| services.AddOptions<AzureMcpServerConfiguration>() | ||
| .Configure<IOptions<ServiceStartOptions>>((options, serviceStartOptions) => | ||
| { | ||
| // Assembly.GetEntryAssembly is used to retrieve the version of the server application as that is | ||
| // the assembly that will run the tool calls. | ||
| var entryAssembly = Assembly.GetEntryAssembly(); | ||
| if (entryAssembly != null) | ||
| { | ||
| options.Version = AssemblyHelper.GetAssemblyVersion(entryAssembly); | ||
| } | ||
|
|
||
| // Disable telemetry when support logging is enabled to prevent sensitive data from being sent | ||
| // to telemetry endpoints. Support logging captures debug-level information that may contain | ||
| // sensitive data, so we disable all telemetry as a safety measure. | ||
| if (!string.IsNullOrWhiteSpace(serviceStartOptions.Value.SupportLoggingFolder)) | ||
| { | ||
| options.IsTelemetryEnabled = false; | ||
| return; | ||
| } | ||
|
|
||
| // This environment variable can be used to disable telemetry collection entirely. This takes precedence | ||
| // over any other settings. | ||
| var collectTelemetry = Environment.GetEnvironmentVariable("AZURE_MCP_COLLECT_TELEMETRY"); | ||
|
|
||
| options.IsTelemetryEnabled = string.IsNullOrWhiteSpace(collectTelemetry) || (bool.TryParse(collectTelemetry, out var shouldCollect) && shouldCollect); | ||
| }); |
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.
This code was moved to ServiceCollectionExtensions.cs. Please rebase and update the configuration there.
What does this PR do?
[Provide a clear, concise description of the changes]Added support logging capability with
--dangerously-enable-support-loggingand--log-file-pathoptions for troubleshooting and support scenarios.[Any additional context, screenshots, or information that helps reviewers]GitHub issue number?
[Link to the GitHub issue this PR addresses]Pre-merge Checklist
servers/Azure.Mcp.Server/CHANGELOG.mdand/orservers/Fabric.Mcp.Server/CHANGELOG.mdfor product changes (features, bug fixes, UI/UX, updated dependencies)servers/Azure.Mcp.Server/README.mdand/orservers/Fabric.Mcp.Server/README.mddocumentationeng/scripts/Process-PackageReadMe.ps1. See Package README/servers/Azure.Mcp.Server/docs/azmcp-commands.mdand/or/docs/fabric-commands.md.\eng\scripts\Update-AzCommandsMetadata.ps1to update tool metadata in azmcp-commands.md (required for CI)ToolDescriptionEvaluatorand obtained a score of0.4or more and a top 3 ranking for all related test promptsconsolidated-tools.json/servers/Azure.Mcp.Server/docs/e2eTestPrompts.mdcrypto mining, spam, data exfiltration, etc.)/azp run mcp - pullrequest - liveto run Live Test Pipeline