Skip to content

Microsoft AI guidance- update MCP package#3154

Draft
souvikghosh04 wants to merge 2 commits intomainfrom
Usr/sogh/msftaiguidance
Draft

Microsoft AI guidance- update MCP package#3154
souvikghosh04 wants to merge 2 commits intomainfrom
Usr/sogh/msftaiguidance

Conversation

@souvikghosh04
Copy link
Contributor

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)

  • Example REST and/or GraphQL request to demonstrate modifications
  • Example of CLI usage to demonstrate modifications

@souvikghosh04 souvikghosh04 added this to the Feb 2026 milestone Feb 24, 2026
@souvikghosh04 souvikghosh04 self-assigned this Feb 24, 2026
@souvikghosh04 souvikghosh04 linked an issue Feb 24, 2026 that may be closed by this pull request
@souvikghosh04 souvikghosh04 moved this from Todo to In Progress in Data API builder Feb 24, 2026
@souvikghosh04
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 6 pipeline(s).

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

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.HttpServer and 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.

Comment on lines +782 to +784
// 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))
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

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).

Suggested change
// 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)

Copilot uses AI. Check for mistakes.
}

List<Tool> tools = toolRegistry.GetAllTools().ToList();
options.ResourceHost = "https://localhost";
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

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.

Suggested change
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;

Copilot uses AI. Check for mistakes.
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.

Microsoft AI guidance on MCP

2 participants