Skip to content

Add MCP probe to comprehensive health endpoint#3685

Open
souvikghosh04 with Copilot wants to merge 11 commits into
mainfrom
copilot/add-mcp-checks-to-health-endpoint
Open

Add MCP probe to comprehensive health endpoint#3685
souvikghosh04 with Copilot wants to merge 11 commits into
mainfrom
copilot/add-mcp-checks-to-health-endpoint

Conversation

Copilot AI commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Why make this change?

  • Closes [Enh]: Add MCP checks to Health Endpoint #2843
  • The comprehensive /health report advertised whether MCP was enabled in its configuration block but never actually probed the MCP endpoint, so MCP outages were invisible to health monitoring.

What is this change?

  • HealthCheckHelper — New UpdateMcpHealthCheckResultsAsync, wired into UpdateHealthCheckDetailsAsync alongside the data-source/entity/embeddings checks. Runs only when IsMcpEnabled; emits a HealthCheckResultEntry named mcp, tagged ["mcp"], comparing response time against the default 1000 ms threshold.
  • HttpUtilities.ExecuteMcpQueryAsync — POSTs a JSON-RPC initialize request to runtimeConfig.McpPath with Accept: application/json, text/event-stream, reusing the existing CheckSanityOfUrl SSRF guard and role-header propagation. initialize is used because tools/list requires an active session under the Streamable HTTP transport.
  • Utilities.CreateHttpMcpQuery — Builds the minimal initialize payload.
  • HealthCheckConstants — Adds the mcp tag.

Single mcp tag (mirroring the data-source check's single data-source tag) rather than reusing endpoint, which is reserved for per-entity REST/GraphQL checks. The check is gated solely on IsMcpEnabled with a default threshold — no new config surface.

How was this tested?

  • Integration Tests — extended ComprehensiveHealthEndpoint_ValidateContents to assert the mcp tag appears iff MCP is enabled.
  • Unit Tests — TestHealthCheckMcpResponseAsync / TestFailureHealthCheckMcpResponseAsync cover success and non-2xx responses.

Sample Request(s)

GET /health

Resulting check entry when MCP is enabled:

{
  "name": "mcp",
  "status": "Healthy",
  "tags": ["mcp"],
  "data": { "duration-ms": 12, "threshold-ms": 1000 }
}

Copilot AI changed the title [WIP] Add MCP checks to health endpoint Add MCP probe to comprehensive health endpoint Jun 26, 2026
Copilot AI requested a review from souvikghosh04 June 26, 2026 08:26
@souvikghosh04 souvikghosh04 marked this pull request as ready for review June 26, 2026 09:37
Copilot AI review requested due to automatic review settings June 26, 2026 09:37
@souvikghosh04 souvikghosh04 modified the milestones: July 2026, June 2026 Jun 26, 2026
@souvikghosh04 souvikghosh04 moved this from Todo to In Progress in Data API builder Jun 26, 2026
@souvikghosh04 souvikghosh04 moved this from In Progress to Review In Progress in Data API builder Jun 26, 2026

Copilot AI commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@copilot review and address the review comments [Add MCP probe to comprehensive health endpoint by Copilot · Pull Request #3685 · Azure/data-api-builder](https://github.com/Azure/data-api-builder/pu...

Addressed in cb6fa46. I fixed the MCP review nits: added the missing semicolon in HttpUtilities, removed hardcoded MCP protocol/client version values by sourcing from McpProtocolDefaults, and tightened the MCP health-check test to assert the full initialize payload and required Accept headers.

Comment thread src/Service/HealthCheck/Utilities.cs
Comment thread src/Service/HealthCheck/Utilities.cs Outdated

Copilot AI commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@copilot review and address the review comments [Add MCP probe to comprehensive health endpoint by Copilot · Pull Request #3685 · Azure/data-api-builder](https://github.com/Azure/data-api-builder/pu...

Addressed the latest follow-up comments in 29de25a (updated MCP health-check clientInfo.version to "1.0.0") and validated with targeted build/tests.

@souvikghosh04 souvikghosh04 enabled auto-merge (squash) July 3, 2026 14:30
@souvikghosh04

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 6 pipeline(s).

@souvikghosh04

Copy link
Copy Markdown
Contributor

@copilot the Unit test "EmbeddingsHealthCheck_OverallStatusHealthy_WhenEmbeddingCheckIsHealthy" is failing in assertion. details- "at Azure.DataApiBuilder.Service.Tests.UnitTests.EmbeddingsHealthCheckTests.EmbeddingsHealthCheck_OverallStatusHealthy_WhenEmbeddingCheckIsHealthy() in /home/vsts/work/1/s/src/Service.Tests/UnitTests/EmbeddingsHealthCheckTests.cs:line 144
"

Copilot AI commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

@copilot the Unit test "EmbeddingsHealthCheck_OverallStatusHealthy_WhenEmbeddingCheckIsHealthy" is failing in assertion. details- "at Azure.DataApiBuilder.Service.Tests.UnitTests.EmbeddingsHealthCheck...

Fixed in a986526. The embeddings unit-test runtime config now disables MCP (McpRuntimeOptions(Enabled: false)) so these tests remain isolated to embeddings health behavior, and EmbeddingsHealthCheckTests passes locally.

@souvikghosh04

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 6 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Review In Progress

Development

Successfully merging this pull request may close these issues.

[Enh]: Add MCP checks to Health Endpoint

5 participants