Microsoft AI guidance- update MCP package#3154
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 6 pipeline(s). |
There was a problem hiding this comment.
Pull request overview
Migrates DAB’s MCP hosting layer from the community MCP SDK to Microsoft’s Microsoft.ModelContextProtocol.HttpServer, updating service registration, endpoint mapping, middleware, and related telemetry/content handling to support the new package and enterprise features (Entra ID/MISE, rate limiting, OTel).
Changes:
- Swaps MCP NuGet dependencies to
Microsoft.ModelContextProtocol.HttpServerand updates NuGet feed/source mapping. - Updates MCP server setup to conditionally use Microsoft MCP pipeline when Entra ID is configured; otherwise falls back to base MCP server.
- Adjusts telemetry and MCP response/test helpers for API changes (OTel exception recording, MCP content blocks).
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Service/Startup.cs | Passes IConfiguration into MCP registration and conditionally adds Microsoft MCP middleware. |
| src/Service.Tests/UnitTests/McpTelemetryTests.cs | Updates test helper to stop setting read-only/removed TextContentBlock.Type. |
| src/Directory.Packages.props | Replaces community MCP packages with Microsoft MCP HttpServer and bumps several related dependency versions. |
| src/Core/Telemetry/TelemetryTracesHelper.cs | Updates exception/status reporting on Activity for newer telemetry APIs. |
| src/Azure.DataApiBuilder.Mcp/Utils/McpResponseBuilder.cs | Updates MCP response content construction for the new SDK shape. |
| src/Azure.DataApiBuilder.Mcp/Core/McpToolRegistry.cs | Avoids duplicate-registration errors by skipping same-instance re-registration. |
| src/Azure.DataApiBuilder.Mcp/Core/McpServiceCollectionExtensions.cs | Threads IConfiguration into MCP registration and exposes Entra-config check. |
| src/Azure.DataApiBuilder.Mcp/Core/McpServerConfiguration.cs | Selects Microsoft vs base MCP server builder and wires tool handlers + HTTP transport. |
| src/Azure.DataApiBuilder.Mcp/Core/McpEndpointRouteBuilderExtensions.cs | Conditionally maps Microsoft MCP endpoints when Entra ID is configured. |
| src/Azure.DataApiBuilder.Mcp/Azure.DataApiBuilder.Mcp.csproj | Replaces community MCP package refs with Microsoft MCP HttpServer. |
| Nuget.config | Adds EngThrive-MCP feed and package source mapping for MCP/MISE packages. |
| // Only use Microsoft MCP middleware (MISE/Entra ID auth, rate limiting) when AzureAd is configured. | ||
| // When AzureAd is not configured, base MCP endpoints are used without enterprise auth. | ||
| if (McpServiceCollectionExtensions.IsEntraIdConfigured(Configuration)) |
There was a problem hiding this comment.
UseMicrosoftMcpServer() is enabled solely based on AzureAd:ClientId. If Entra ID is configured for REST/GraphQL but MCP is disabled (or MCP services weren’t registered because runtime config wasn’t available), this middleware can be added without the corresponding MCP server/endpoints and may cause startup/request failures. Gate this middleware on MCP being enabled/registered as well (e.g., check runtimeConfig.Runtime.Mcp.Enabled in addition to Entra config).
| // Only use Microsoft MCP middleware (MISE/Entra ID auth, rate limiting) when AzureAd is configured. | |
| // When AzureAd is not configured, base MCP endpoints are used without enterprise auth. | |
| if (McpServiceCollectionExtensions.IsEntraIdConfigured(Configuration)) | |
| // Only use Microsoft MCP middleware (MISE/Entra ID auth, rate limiting) when AzureAd is configured | |
| // and MCP is enabled in the runtime configuration. When AzureAd is not configured or MCP is disabled, | |
| // base MCP endpoints are used without enterprise auth. | |
| if (McpServiceCollectionExtensions.IsEntraIdConfigured(Configuration) | |
| && runtimeConfig?.Runtime?.Mcp?.Enabled is true) |
| } | ||
|
|
||
| List<Tool> tools = toolRegistry.GetAllTools().ToList(); | ||
| options.ResourceHost = "https://localhost"; |
There was a problem hiding this comment.
options.ResourceHost is hard-coded to https://localhost. In any non-local deployment this will be wrong and can break Entra ID/MISE flows (and potentially emit incorrect URLs in responses/metadata). Make this derive from configuration (or from the incoming request host behind forwarded headers) instead of a fixed localhost value.
| options.ResourceHost = "https://localhost"; | |
| // Prefer a configured ResourceHost, fall back to localhost for development. | |
| string? configuredResourceHost = configuration["Mcp:ResourceHost"]; | |
| options.ResourceHost = string.IsNullOrEmpty(configuredResourceHost) | |
| ? "https://localhost" | |
| : configuredResourceHost; |
Why make this change?
Closes on - #3021
Migrate DAB's MCP layer from the community SDK (ModelContextProtocol 0.3.0-preview.4) to Microsoft's official Microsoft.ModelContextProtocol.HttpServer (0.1.0-preview.25) for Entra ID authentication, MISE integration, rate limiting, and first-party OpenTelemetry support.
What is this change?
Package swap: Replaced two community NuGet packages with single Microsoft.ModelContextProtocol.HttpServer. Added EngThrive-MCP ADO feed + package source mapping. Bumped transitive deps (OpenTelemetry 1.9→1.12/1.13, Configuration.Binder 8.0→9.0).
API adoption: AddMcpServer → AddMicrosoftMcpServer, MapMcp → MapMicrosoftMcpServer, added UseMicrosoftMcpServer middleware.
Conditional auth: Full Microsoft pipeline (Entra ID, MISE, rate limiting) when AzureAd:ClientId is configured; base AddMcpServer pipeline otherwise — prevents MISE crash in dev mode.
Breaking change fixes: Removed read-only TextContentBlock.Type assignments. Replaced deprecated OTel APIs. Removed unused using OpenTelemetry.Trace.
Stdio fix: McpToolRegistry.RegisterTool() now skips same-instance re-registration to prevent duplicate errors in stdio mode.
11 files changed across package management (3), MCP core (4), utils (1), service (1), telemetry (1), tests (1).
How was this tested?
Unit Tests — 77 MCP-related tests pass (65 Service.Tests + 12 Cli.Tests)
Integration Tests (manual) — HTTP and stdio transports validated end-to-end (initialize, tools/list, CRUD operations, shutdown). Dev mode startup without Entra ID — no MISE crash.
Sample Request(s)