Skip to content

Add MCP probe to comprehensive health endpoint#3685

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

Add MCP probe to comprehensive health endpoint#3685
Copilot wants to merge 6 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 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an MCP probe to the comprehensive /health endpoint so that MCP availability and response time are reflected in health monitoring when MCP is enabled.

Changes:

  • Added a minimal JSON-RPC initialize payload builder for MCP health probing.
  • Implemented HttpUtilities.ExecuteMcpQueryAsync and wired an MCP check into HealthCheckHelper.UpdateHealthCheckDetailsAsync.
  • Extended health endpoint tests and introduced the mcp health-check tag constant.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/Service/HealthCheck/Utilities.cs Adds helper to create a minimal MCP initialize JSON-RPC request payload.
src/Service/HealthCheck/HttpUtilities.cs Adds an MCP POST probe method for the health check HTTP client.
src/Service/HealthCheck/HealthCheckHelper.cs Wires MCP probing into comprehensive health checks and records duration/threshold.
src/Service.Tests/Configuration/HealthEndpointTests.cs Extends comprehensive health assertions and adds MCP request unit tests.
src/Config/HealthCheck/HealthCheckConstants.cs Adds the mcp tag constant.

Comment thread src/Service/HealthCheck/HttpUtilities.cs Outdated
Comment thread src/Service/HealthCheck/HealthCheckHelper.cs
Comment thread src/Service.Tests/Configuration/HealthEndpointTests.cs
souvikghosh04 and others added 4 commits June 30, 2026 11:16
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@aaronburtle

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

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

HttpRequestMessage message = new(method: HttpMethod.Post, requestUri: requestUri)
{
Content = content
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: think this is missing a semi-colon on the object initializer here.

method = "initialize",
@params = new
{
protocolVersion = "2025-03-26",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SHould the protocolVersion be hardcoded here or can we source this from somewhere?

@aaronburtle aaronburtle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good just a couple nits

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