Skip to content

Conversation

@xiangyan99
Copy link
Member

What does this PR do?

[Provide a clear, concise description of the changes]

Added support logging capability with --dangerously-enable-support-logging and --log-file-path options 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

  • Required for All PRs
    • Read contribution guidelines
    • PR title clearly describes the change
    • Commit history is clean with descriptive messages (cleanup guide)
    • Added comprehensive tests for new/modified functionality
    • Updated servers/Azure.Mcp.Server/CHANGELOG.md and/or servers/Fabric.Mcp.Server/CHANGELOG.md for product changes (features, bug fixes, UI/UX, updated dependencies)
  • For MCP tool changes:
    • One tool per PR: This PR adds or modifies only one MCP tool for faster review cycles
    • Updated servers/Azure.Mcp.Server/README.md and/or servers/Fabric.Mcp.Server/README.md documentation
    • Validate README.md changes using script at eng/scripts/Process-PackageReadMe.ps1. See Package README
    • Updated command list in /servers/Azure.Mcp.Server/docs/azmcp-commands.md and/or /docs/fabric-commands.md
    • Run .\eng\scripts\Update-AzCommandsMetadata.ps1 to update tool metadata in azmcp-commands.md (required for CI)
    • For new or modified tool descriptions, ran ToolDescriptionEvaluator and obtained a score of 0.4 or more and a top 3 ranking for all related test prompts
    • For tools with new names, including new tools or renamed tools, update consolidated-tools.json
    • For new tools associated with Azure services or publicly available tools/APIs/products, add URL to documentation in the PR description
  • Extra steps for Azure MCP Server tool changes:
    • Updated test prompts in /servers/Azure.Mcp.Server/docs/e2eTestPrompts.md
    • 👉 For Community (non-Microsoft team member) PRs:
      • Security review: Reviewed code for security vulnerabilities, malicious code, or suspicious activities before running tests (crypto mining, spam, data exfiltration, etc.)
      • Manual tests run: added comment /azp run mcp - pullrequest - live to run Live Test Pipeline

command.Options.Add(ServiceOptionDefinitions.DangerouslyDisableHttpIncomingAuth);
command.Options.Add(ServiceOptionDefinitions.InsecureDisableElicitation);
command.Options.Add(ServiceOptionDefinitions.OutgoingAuthStrategy);
command.Options.Add(ServiceOptionDefinitions.DangerouslyEnableSupportLoggingToFolder);
Copy link
Member

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))
Copy link
Member

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))
Copy link
Member

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))
Copy link
Member

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?

Comment on lines 239 to 250
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] ";
});
Copy link
Member

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?

Comment on lines 31 to 56
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);
});
Copy link
Member

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.

@xiangyan99 xiangyan99 changed the title Add DangerouslyEnableSupportLogging support Add DangerouslyWriteSupportLogsToDir support Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

3 participants