diff --git a/core/Azure.Mcp.Core/src/Areas/Server/Commands/ServiceStartCommand.cs b/core/Azure.Mcp.Core/src/Areas/Server/Commands/ServiceStartCommand.cs index 9380167e4..84ba7d534 100644 --- a/core/Azure.Mcp.Core/src/Areas/Server/Commands/ServiceStartCommand.cs +++ b/core/Azure.Mcp.Core/src/Areas/Server/Commands/ServiceStartCommand.cs @@ -19,7 +19,6 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.Identity.Web; -using Microsoft.IdentityModel.Tokens; using OpenTelemetry.Logs; using OpenTelemetry.Metrics; using OpenTelemetry.Trace; diff --git a/core/Azure.Mcp.Core/src/Extensions/OpenTelemetryExtensions.cs b/core/Azure.Mcp.Core/src/Extensions/OpenTelemetryExtensions.cs index 70e510cd1..c6fb3803c 100644 --- a/core/Azure.Mcp.Core/src/Extensions/OpenTelemetryExtensions.cs +++ b/core/Azure.Mcp.Core/src/Extensions/OpenTelemetryExtensions.cs @@ -3,14 +3,13 @@ using System.Reflection; using System.Runtime.InteropServices; +using Azure.Mcp.Core.Areas.Server.Options; using Azure.Mcp.Core.Configuration; using Azure.Mcp.Core.Services.Telemetry; -using Azure.Monitor.OpenTelemetry.Exporter; using Microsoft.Extensions.Azure; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using OpenTelemetry; using OpenTelemetry.Logs; using OpenTelemetry.Metrics; using OpenTelemetry.Resources; @@ -25,14 +24,21 @@ public static class OpenTelemetryExtensions public static void ConfigureOpenTelemetry(this IServiceCollection services) { services.AddOptions() - .Configure(options => + .Configure>((options, serviceStartOptions) => { options.Version = GetServerVersion(Assembly.GetCallingAssembly()); var collectTelemetry = Environment.GetEnvironmentVariable("AZURE_MCP_COLLECT_TELEMETRY"); - options.IsTelemetryEnabled = string.IsNullOrEmpty(collectTelemetry) - || (bool.TryParse(collectTelemetry, out var shouldCollect) && shouldCollect); + var transport = serviceStartOptions.Value.Transport; + + bool isTelemetryEnabledEnvironment = string.IsNullOrEmpty(collectTelemetry) || (bool.TryParse(collectTelemetry, out var shouldCollect) && shouldCollect); + + bool isStdioTransport = string.IsNullOrEmpty(transport) || string.Equals(transport, "stdio", StringComparison.OrdinalIgnoreCase); + + // if transport is not set (default to stdio) or is set to stdio, enable telemetry + // telemetry is disabled for HTTP transport + options.IsTelemetryEnabled = isTelemetryEnabledEnvironment && isStdioTransport; }); services.AddSingleton(); diff --git a/servers/Azure.Mcp.Server/CHANGELOG.md b/servers/Azure.Mcp.Server/CHANGELOG.md index d7eab390e..5f90c310a 100644 --- a/servers/Azure.Mcp.Server/CHANGELOG.md +++ b/servers/Azure.Mcp.Server/CHANGELOG.md @@ -23,6 +23,7 @@ The Azure MCP Server updates automatically by default whenever a new release com - Updates `AzureMcpServerConfiguration.Version` to use value from `AssemblyInformationalVersionAttribute` rather than file version to support semver conventions such as -beta.1. [[#1040](https://github.com/microsoft/mcp/pull/1040)] - Added a `CancellationToken` parameter `IBaseCommand.ExecuteAsync()` [[#1056](https://github.com/microsoft/mcp/pull/1056)] - Added a `CancellationToken` parameter to async methods to many, but not yet all, `I[SomeService]` interfaces [[#1056](https://github.com/microsoft/mcp/pull/1056)] +- Disabled telemetry for HTTP transport [[#1072](https://github.com/microsoft/mcp/pull/1072)] ## 2.0.0-beta.1 (2025-10-29) diff --git a/servers/Azure.Mcp.Server/src/Properties/launchSettings.json b/servers/Azure.Mcp.Server/src/Properties/launchSettings.json index 609c0bbca..6702182ee 100644 --- a/servers/Azure.Mcp.Server/src/Properties/launchSettings.json +++ b/servers/Azure.Mcp.Server/src/Properties/launchSettings.json @@ -3,7 +3,7 @@ "profiles": { "debug-remotemcp": { "commandName": "Project", - "commandLineArgs": "server start --run-as-remote-http-service --outgoing-auth-strategy UseHostingEnvironmentIdentity", + "commandLineArgs": "server start --transport http --outgoing-auth-strategy UseHostingEnvironmentIdentity", "dotnetRunMessages": true, "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development",