diff --git a/.vscode/cspell.json b/.vscode/cspell.json index e4a22c9522..ea5043d2ee 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -56,6 +56,7 @@ "rohit", "vcolin", "vinay", + "vukelich", "wbreza", "xiangyan" ] diff --git a/core/Microsoft.Mcp.Core/src/Services/Azure/BaseAzureResourceService.cs b/core/Azure.Mcp.Core/src/Services/Azure/BaseAzureResourceService.cs similarity index 100% rename from core/Microsoft.Mcp.Core/src/Services/Azure/BaseAzureResourceService.cs rename to core/Azure.Mcp.Core/src/Services/Azure/BaseAzureResourceService.cs diff --git a/core/Microsoft.Mcp.Core/src/Services/Azure/BaseAzureService.cs b/core/Azure.Mcp.Core/src/Services/Azure/BaseAzureService.cs similarity index 100% rename from core/Microsoft.Mcp.Core/src/Services/Azure/BaseAzureService.cs rename to core/Azure.Mcp.Core/src/Services/Azure/BaseAzureService.cs diff --git a/core/Microsoft.Mcp.Core/src/Services/Azure/ResourceGroup/IResourceGroupService.cs b/core/Azure.Mcp.Core/src/Services/Azure/ResourceGroup/IResourceGroupService.cs similarity index 100% rename from core/Microsoft.Mcp.Core/src/Services/Azure/ResourceGroup/IResourceGroupService.cs rename to core/Azure.Mcp.Core/src/Services/Azure/ResourceGroup/IResourceGroupService.cs diff --git a/core/Microsoft.Mcp.Core/src/Services/Azure/ResourceGroup/ResourceGroupService.cs b/core/Azure.Mcp.Core/src/Services/Azure/ResourceGroup/ResourceGroupService.cs similarity index 100% rename from core/Microsoft.Mcp.Core/src/Services/Azure/ResourceGroup/ResourceGroupService.cs rename to core/Azure.Mcp.Core/src/Services/Azure/ResourceGroup/ResourceGroupService.cs diff --git a/core/Microsoft.Mcp.Core/src/Services/Azure/Subscription/ISubscriptionService.cs b/core/Azure.Mcp.Core/src/Services/Azure/Subscription/ISubscriptionService.cs similarity index 100% rename from core/Microsoft.Mcp.Core/src/Services/Azure/Subscription/ISubscriptionService.cs rename to core/Azure.Mcp.Core/src/Services/Azure/Subscription/ISubscriptionService.cs diff --git a/core/Microsoft.Mcp.Core/src/Services/Azure/Subscription/SubscriptionService.cs b/core/Azure.Mcp.Core/src/Services/Azure/Subscription/SubscriptionService.cs similarity index 100% rename from core/Microsoft.Mcp.Core/src/Services/Azure/Subscription/SubscriptionService.cs rename to core/Azure.Mcp.Core/src/Services/Azure/Subscription/SubscriptionService.cs diff --git a/core/Microsoft.Mcp.Core/src/Services/Azure/Tenant/ITenantService.cs b/core/Azure.Mcp.Core/src/Services/Azure/Tenant/ITenantService.cs similarity index 100% rename from core/Microsoft.Mcp.Core/src/Services/Azure/Tenant/ITenantService.cs rename to core/Azure.Mcp.Core/src/Services/Azure/Tenant/ITenantService.cs diff --git a/core/Microsoft.Mcp.Core/src/Services/Azure/Tenant/TenantService.cs b/core/Azure.Mcp.Core/src/Services/Azure/Tenant/TenantService.cs similarity index 100% rename from core/Microsoft.Mcp.Core/src/Services/Azure/Tenant/TenantService.cs rename to core/Azure.Mcp.Core/src/Services/Azure/Tenant/TenantService.cs diff --git a/core/Microsoft.Mcp.Core/src/Services/Azure/Tenant/TenantServiceCollectionExtensions.cs b/core/Azure.Mcp.Core/src/Services/Azure/Tenant/TenantServiceCollectionExtensions.cs similarity index 100% rename from core/Microsoft.Mcp.Core/src/Services/Azure/Tenant/TenantServiceCollectionExtensions.cs rename to core/Azure.Mcp.Core/src/Services/Azure/Tenant/TenantServiceCollectionExtensions.cs diff --git a/core/Microsoft.Mcp.Core/src/Areas/Server/Commands/ServiceStartCommand.cs b/core/Microsoft.Mcp.Core/src/Areas/Server/Commands/ServiceStartCommand.cs index 284f444c85..609955d7b2 100644 --- a/core/Microsoft.Mcp.Core/src/Areas/Server/Commands/ServiceStartCommand.cs +++ b/core/Microsoft.Mcp.Core/src/Areas/Server/Commands/ServiceStartCommand.cs @@ -182,10 +182,6 @@ public override async Task ExecuteAsync(CommandContext context, var options = BindOptions(parseResult); - // Update the UserAgentPolicy for all Azure service calls to include the transport type. - var transport = string.IsNullOrEmpty(options.Transport) ? TransportTypes.StdIo : options.Transport; - BaseAzureService.InitializeUserAgentPolicy(transport); - try { using var tracerProvider = AddIncomingAndOutgoingHttpSpans(options); diff --git a/core/Microsoft.Mcp.Core/src/Areas/Server/Options/TransportTypes.cs b/core/Microsoft.Mcp.Core/src/Areas/Server/Options/TransportTypes.cs index 51002fa5d1..489c5169d9 100644 --- a/core/Microsoft.Mcp.Core/src/Areas/Server/Options/TransportTypes.cs +++ b/core/Microsoft.Mcp.Core/src/Areas/Server/Options/TransportTypes.cs @@ -6,7 +6,7 @@ namespace Azure.Mcp.Core.Areas.Server.Options; /// /// Defines the supported transport mechanisms for the Azure MCP server. /// -internal static class TransportTypes +public static class TransportTypes { /// /// Standard Input/Output transport mechanism. diff --git a/core/Microsoft.Mcp.Core/src/Services/Azure/Authentication/IAzureTokenCredentialProvider.cs b/core/Microsoft.Mcp.Core/src/Services/Azure/Authentication/IAzureTokenCredentialProvider.cs index 3447ec48b0..36550de787 100644 --- a/core/Microsoft.Mcp.Core/src/Services/Azure/Authentication/IAzureTokenCredentialProvider.cs +++ b/core/Microsoft.Mcp.Core/src/Services/Azure/Authentication/IAzureTokenCredentialProvider.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using Azure.Core; -using Azure.Mcp.Core.Services.Azure.Tenant; using Microsoft.Extensions.DependencyInjection; namespace Azure.Mcp.Core.Services.Azure.Authentication; @@ -10,7 +9,7 @@ namespace Azure.Mcp.Core.Services.Azure.Authentication; /// /// Providers instances of appropriate for the current environment. /// Implementations are expected to be of , however, in -/// multi-user enviornments using on-behalf-of downstream authentication, the implementation +/// multi-user environments using on-behalf-of downstream authentication, the implementation /// must return credentials within the context of the user in the current execution context. /// /// diff --git a/servers/Azure.Mcp.Server/src/Program.cs b/servers/Azure.Mcp.Server/src/Program.cs index f9b3765244..e37b883f7f 100644 --- a/servers/Azure.Mcp.Server/src/Program.cs +++ b/servers/Azure.Mcp.Server/src/Program.cs @@ -4,8 +4,10 @@ using System.Net; using Azure.Mcp.Core.Areas.Server; using Azure.Mcp.Core.Areas.Server.Commands; +using Azure.Mcp.Core.Areas.Server.Options; using Azure.Mcp.Core.Commands; using Azure.Mcp.Core.Helpers; +using Azure.Mcp.Core.Services.Azure; using Azure.Mcp.Core.Services.Azure.ResourceGroup; using Azure.Mcp.Core.Services.Azure.Subscription; using Azure.Mcp.Core.Services.Azure.Tenant; @@ -15,6 +17,7 @@ using Azure.Mcp.Core.Services.Time; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; using Microsoft.Mcp.Core.Areas; using Microsoft.Mcp.Core.Commands; using Microsoft.Mcp.Core.Models.Command; @@ -162,7 +165,7 @@ private static void WriteResponse(CommandResponse response) /// /// 's command picking: The container used to populate instances of /// and selected by - /// baesd on the command line input. This container is a local variable in + /// based on the command line input. This container is a local variable in /// , and it is not tied to /// Microsoft.Extensions.Hosting.IHostBuilder (stdio) nor any /// Microsoft.AspNetCore.Hosting.IWebHostBuilder (http). @@ -188,7 +191,7 @@ private static void WriteResponse(CommandResponse response) /// on or , both of which have /// transport-specific implementations. This method can add the stdio-specific /// implementation to allow the first container (used for command picking) to work, - /// but such transport-specific registrations must be overriden within + /// but such transport-specific registrations must be overridden within /// with the appropriate /// transport-specific implementation based on command line arguments. /// @@ -216,7 +219,7 @@ internal static void ConfigureServices(IServiceCollection services) // !!! WARNING !!! // stdio-transport-specific implementations of ITenantService and ICacheService. - // The http-traport-specific implementations and configurations must be registered + // The http-transport-specific implementations and configurations must be registered // within ServiceStartCommand.ExecuteAsync(). services.AddHttpClientServices(configureDefaults: true); services.AddAzureTenantService(); @@ -233,6 +236,15 @@ internal static void ConfigureServices(IServiceCollection services) internal static async Task InitializeServicesAsync(IServiceProvider serviceProvider) { + ServiceStartOptions? options = serviceProvider.GetService>()?.Value; + + if (options != null) + { + // Update the UserAgentPolicy for all Azure service calls to include the transport type. + var transport = string.IsNullOrEmpty(options.Transport) ? TransportTypes.StdIo : options.Transport; + BaseAzureService.InitializeUserAgentPolicy(transport); + } + // Perform any initialization before starting the service. // If the initialization operation fails, do not continue because we do not want // invalid telemetry published. diff --git a/servers/Fabric.Mcp.Server/src/Program.cs b/servers/Fabric.Mcp.Server/src/Program.cs index ebc7db9737..33f437e637 100644 --- a/servers/Fabric.Mcp.Server/src/Program.cs +++ b/servers/Fabric.Mcp.Server/src/Program.cs @@ -8,9 +8,6 @@ using Azure.Mcp.Core.Commands; using Azure.Mcp.Core.Extensions; using Azure.Mcp.Core.Models; -using Azure.Mcp.Core.Services.Azure.ResourceGroup; -using Azure.Mcp.Core.Services.Azure.Subscription; -using Azure.Mcp.Core.Services.Azure.Tenant; using Azure.Mcp.Core.Services.Caching; using Azure.Mcp.Core.Services.ProcessExecution; using Azure.Mcp.Core.Services.Telemetry; @@ -97,7 +94,7 @@ private static void WriteResponse(CommandResponse response) /// /// 's command picking: The container used to populate instances of /// and selected by - /// baesd on the command line input. This container is a local variable in + /// based on the command line input. This container is a local variable in /// , and it is not tied to /// Microsoft.Extensions.Hosting.IHostBuilder (stdio) nor any /// Microsoft.AspNetCore.Hosting.IWebHostBuilder (http). @@ -123,7 +120,7 @@ private static void WriteResponse(CommandResponse response) /// on or , both of which have /// transport-specific implementations. This method can add the stdio-specific /// implementation to allow the first container (used for command picking) to work, - /// but such transport-specific registrations must be overriden within + /// but such transport-specific registrations must be overridden within /// with the appropriate /// transport-specific implementation based on command line arguments. /// @@ -145,16 +142,13 @@ internal static void ConfigureServices(IServiceCollection services) services.AddMemoryCache(); services.AddSingleton(); services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); services.AddSingleton(); // !!! WARNING !!! // stdio-transport-specific implementations of ITenantService and ICacheService. - // The http-traport-specific implementations and configurations must be registered + // The http-transport-specific implementations and configurations must be registered // within ServiceStartCommand.ExecuteAsync(). services.AddHttpClientServices(); - services.AddAzureTenantService(); services.AddSingleUserCliCacheService(); foreach (var area in Areas) diff --git a/servers/Template.Mcp.Server/src/Program.cs b/servers/Template.Mcp.Server/src/Program.cs index a4c4e3612b..4063f27fd0 100644 --- a/servers/Template.Mcp.Server/src/Program.cs +++ b/servers/Template.Mcp.Server/src/Program.cs @@ -91,7 +91,7 @@ private static void WriteResponse(CommandResponse response) /// /// 's command picking: The container used to populate instances of /// and selected by - /// baesd on the command line input. This container is a local variable in + /// based on the command line input. This container is a local variable in /// , and it is not tied to /// Microsoft.Extensions.Hosting.IHostBuilder (stdio) nor any /// Microsoft.AspNetCore.Hosting.IWebHostBuilder (http). @@ -117,7 +117,7 @@ private static void WriteResponse(CommandResponse response) /// on or , both of which have /// transport-specific implementations. This method can add the stdio-specific /// implementation to allow the first container (used for command picking) to work, - /// but such transport-specific registrations must be overriden within + /// but such transport-specific registrations must be overridden within /// with the appropriate /// transport-specific implementation based on command line arguments. /// @@ -143,7 +143,7 @@ internal static void ConfigureServices(IServiceCollection services) // !!! WARNING !!! // stdio-transport-specific implementations of ICacheService. - // The http-traport-specific implementations and configurations must be registered + // The http-transport-specific implementations and configurations must be registered // within ServiceStartCommand.ExecuteAsync(). services.AddSingleUserCliCacheService();