Skip to content

Conversation

@conniey
Copy link
Member

@conniey conniey commented Nov 7, 2025

What does this PR do?

[Provide a clear, concise description of the changes]

Related issues from migration

[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 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

Copilot AI review requested due to automatic review settings November 7, 2025 21:17
@conniey conniey requested review from a team as code owners November 7, 2025 21:17
@github-project-automation github-project-automation bot moved this to Untriaged in Azure MCP Server Nov 7, 2025
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 refactors the configuration system to use appsettings.json files with the Host.CreateApplicationBuilder pattern, moving away from manual service collection construction. The changes enable AOT-compatible configuration binding and centralize server configuration (name, prefix, display name) in appsettings.json files.

Key changes:

  • Introduced appsettings.json files for server configuration across multiple servers
  • Updated AzureMcpServerConfiguration to include required properties (Prefix, Name, DisplayName) with data annotations
  • Refactored Program.cs files to use Host.CreateApplicationBuilder instead of direct ServiceCollection instantiation

Reviewed Changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
servers/Template.Mcp.Server/src/appsettings.json Added configuration file with server metadata
servers/Template.Mcp.Server/src/appsettings.Development.json Added development logging configuration
servers/Template.Mcp.Server/src/Template.Mcp.Server.csproj Added content items to copy appsettings files to output
servers/Template.Mcp.Server/src/Program.cs Refactored to use Host.CreateApplicationBuilder and pass IHostEnvironment
servers/Fabric.Mcp.Server/src/Program.cs Refactored to use Host.CreateApplicationBuilder and pass IHostEnvironment
servers/Azure.Mcp.Server/src/appsettings.json Added configuration file with server metadata
servers/Azure.Mcp.Server/src/appsettings.Release.json Added release configuration with Application Insights connection string
servers/Azure.Mcp.Server/src/appsettings.Development.json Added development logging configuration with telemetry disabled
servers/Azure.Mcp.Server/src/Properties/launchSettings.json Reformatted and added new "local-stdio" profile
servers/Azure.Mcp.Server/src/Program.cs Refactored to use Host.CreateApplicationBuilder, added Release config loading, and host lifecycle
servers/Azure.Mcp.Server/src/Azure.Mcp.Server.csproj Added conditional content items for configuration files based on build configuration
core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Services/Telemetry/TelemetryServiceTests.cs Updated test configuration instances with new required properties
core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Commands/CommandFactoryTests.cs Added server configuration setup and updated constructor calls
core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Tools/UnitTests/ToolsListCommandTests.cs Updated CommandFactory instantiation with server configuration
core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/Commands/Discovery/ConsolidatedToolDiscoveryStrategyTests.cs Updated strategy instantiation to pass required dependencies explicitly
core/Azure.Mcp.Core/tests/Azure.Mcp.Core.UnitTests/Areas/Server/CommandFactoryHelpers.cs Added default server configuration creation in test helpers
core/Azure.Mcp.Core/src/Extensions/OpenTelemetryExtensions.cs Refactored to accept IHostEnvironment, removed hardcoded connection string, added empty conditional blocks
core/Azure.Mcp.Core/src/Configuration/AzureMcpServerConfigurationValidator.cs Added options validator for server configuration
core/Azure.Mcp.Core/src/Configuration/AzureMcpServerConfiguration.cs Added required properties with data annotations and documentation
core/Azure.Mcp.Core/src/Commands/CommandFactory.cs Updated to use server name from configuration instead of hardcoded value
core/Azure.Mcp.Core/src/Azure.Mcp.Core.csproj Enabled configuration binding generator for AOT compatibility
core/Azure.Mcp.Core/src/Areas/Server/Commands/ServiceStartCommand.cs Refactored to use Host.CreateApplicationBuilder pattern
core/Azure.Mcp.Core/src/Areas/Server/Commands/ServiceCollectionExtensions.cs Extracted configuration setup, moved GetServerVersion method, added ConfigureMcpServerOptions
core/Azure.Mcp.Core/src/Areas/Server/Commands/Discovery/ConsolidatedToolDiscoveryStrategy.cs Updated constructor to accept required dependencies as parameters
Comments suppressed due to low confidence (3)

core/Azure.Mcp.Core/src/Extensions/OpenTelemetryExtensions.cs:94

  • Empty block without comment.
        {

        }

core/Azure.Mcp.Core/src/Extensions/OpenTelemetryExtensions.cs:94

  • If-statement with an empty then-branch and no else-branch.
        else if(hostEnvironment.IsDevelopment())
        {

        }

core/Azure.Mcp.Core/src/Areas/Server/Commands/ServiceCollectionExtensions.cs:54

                    var mcpServerOptionsBuilder = services.AddOptions<McpServerOptions>();

});

}
else if(hostEnvironment.IsDevelopment())
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after 'if' keyword. Should be else if (hostEnvironment.IsDevelopment()) to follow C# coding conventions.

Suggested change
else if(hostEnvironment.IsDevelopment())
else if (hostEnvironment.IsDevelopment())

Copilot uses AI. Check for mistakes.
await InitializeServicesAsync(host.Services);

// Starts any IHostedServices
await host.StartAsync();
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starting the host before invoking the command will cause the application to hang indefinitely. The host.StartAsync() call starts background services and keeps them running. This should either be removed or the application lifecycle should be refactored to properly manage the host. Consider whether hosted services are needed here, or if the host should be started only when running in HTTP mode.

Suggested change
await host.StartAsync();
// await host.StartAsync(); // Removed to prevent application hang

Copilot uses AI. Check for mistakes.
@conniey conniey changed the title (wip) Remove hard coded strings. Use configuration. Remove hard coded strings. Migrate to use IConfiguration Nov 10, 2025
@joshfree joshfree moved this from Untriaged to In Progress in Azure MCP Server Nov 10, 2025
@joshfree joshfree added this to the 2025-11 milestone Nov 10, 2025
@@ -0,0 +1,22 @@
{
"AZURE_MCP_COLLECT_TELEMETRY": "false",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we want this to be true and AZURE_MCP_ENABLE_OTLP_EXPORTER. But we don't want to have the Application Insights connection string injected.

_logger = logger;
_rootGroup = new CommandGroup(RootCommandGroupName, "Azure MCP Server");
_serverName = serverConfig.Value.Name;
_rootGroup = new CommandGroup(_serverName, serverConfig.Value.DisplayName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be using serverConfig.Value.Prefix for CommandGroup name?

Suggested change
_rootGroup = new CommandGroup(_serverName, serverConfig.Value.DisplayName);
_rootGroup = new CommandGroup(serverConfig.Value.Prefix, serverConfig.Value.DisplayName);

Won't this be changing azmcp to Azure.Mcp.Server

https://github.com/microsoft/mcp/pull/1112/files#diff-84afbeb80efc4b997ac0d0a1be89ae59bb0492f484a35fcd996a7797b654dc1aR3

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But maybe we should rename prefix to RootCommandName?


builder.AddAzureMonitorMetricExporter(options =>
{
options.ConnectionString = config.ApplicationInsightsConnectionString;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does Azure Monitor do when the connection string is missing / null / empty?

Should configuration of Azure Monitor be guarded by the state of the connection string?

@conniey conniey requested a review from a team as a code owner November 13, 2025 00:10
@conniey conniey mentioned this pull request Nov 13, 2025
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

4 participants