Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 23, 2025

The MCP Inspector integration fails when MCP servers only expose HTTPS endpoints, throwing InvalidOperationException because it only checks for HTTP.

Changes

  • McpInspectorResource.cs: Prefer HTTPS over HTTP when resolving endpoints

    // Before: only checked "http"
    mcpServer.GetEndpoint("http") ?? throw new InvalidOperationException(...)
    
    // After: check "https" first, fallback to "http"
    mcpServer.GetEndpoint("https") ?? mcpServer.GetEndpoint("http") ?? throw new InvalidOperationException(...)
  • Tests: Added coverage for HTTPS-only, HTTP-only, and both endpoints scenarios

Follows the existing pattern in JavaScriptHostingExtensions.cs for endpoint resolution.

Original prompt

This section details on the original issue you should resolve

<issue_title>MCP Inspector does not work with https endpoint</issue_title>
<issue_description>### Describe the bug

The MCP Inspector integration only looks for a "http" endpoint, not for "https".

mcpServer.GetEndpoint("http") ?? throw new InvalidOperationException($"The MCP server {mcpServer.Name} must have a 'http' endpoint defined."),

My app only exposes "https", so it throws an exception.

Changing it to

mcpServer.GetEndpoint("https") ?? mcpServer.GetEndpoint("http") ?? throw new InvalidOperationException($"The MCP server {mcpServer.Name} must have a 'http' endpoint defined."),

would make it work and also use https by default which it should do anyway.

Regression

no

Steps to reproduce

See above

Expected behavior

It should work with https endpoints.

Screenshots

No response

IDE and version

Other

IDE version

No response

Nuget packages

CommunityToolkit.Aspire.Hosting.McpInspector (13.0.0-beta.444)

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix MCP Inspector to support https endpoints Fix MCP Inspector to support HTTPS endpoints Nov 23, 2025
Copilot AI requested a review from aaronpowell November 23, 2025 03:09
@aaronpowell aaronpowell marked this pull request as ready for review November 23, 2025 03:11
Copilot AI review requested due to automatic review settings November 23, 2025 03:11
@github-actions
Copy link
Contributor

Code Coverage

Package Line Rate Branch Rate Complexity Health
CommunityToolkit.Aspire.GoFeatureFlag 100% 97% 74
CommunityToolkit.Aspire.Hosting.ActiveMQ 78% 40% 108
CommunityToolkit.Aspire.Hosting.ActiveMQ.MassTransit 1% 0% 14
CommunityToolkit.Aspire.Hosting.Adminer 73% 50% 20
CommunityToolkit.Aspire.Hosting.Azure.Dapr 29% 7% 124
CommunityToolkit.Aspire.Hosting.Azure.Dapr.Redis 61% 34% 76
CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder 100% 100% 22
CommunityToolkit.Aspire.Hosting.Bun 96% 83% 28
CommunityToolkit.Aspire.Hosting.Dapr 60% 37% 840
CommunityToolkit.Aspire.Hosting.DbGate 94% 50% 18
CommunityToolkit.Aspire.Hosting.Deno 98% 85% 44
CommunityToolkit.Aspire.Hosting.Flagd 79% 100% 32
CommunityToolkit.Aspire.Hosting.GoFeatureFlag 88% 73% 36
CommunityToolkit.Aspire.Hosting.Golang 51% 40% 88
CommunityToolkit.Aspire.Hosting.Java 70% 75% 130
CommunityToolkit.Aspire.Hosting.JavaScript.Extensions 97% 85% 200
CommunityToolkit.Aspire.Hosting.k6 58% 12% 20
CommunityToolkit.Aspire.Hosting.Keycloak.Extensions 100% 100% 22
CommunityToolkit.Aspire.Hosting.KurrentDB 71% 75% 34
CommunityToolkit.Aspire.Hosting.LavinMQ 74% 50% 26
CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit 1% 0% 14
CommunityToolkit.Aspire.Hosting.MailPit 85% 50% 22
CommunityToolkit.Aspire.Hosting.McpInspector 75% 39% 154
CommunityToolkit.Aspire.Hosting.Meilisearch 71% 57% 58
CommunityToolkit.Aspire.Hosting.Minio 88% 75% 56
CommunityToolkit.Aspire.Hosting.MongoDB.Extensions 96% 83% 36
CommunityToolkit.Aspire.Hosting.MySql.Extensions 100% 88% 78
CommunityToolkit.Aspire.Hosting.Ngrok 52% 35% 82
CommunityToolkit.Aspire.Hosting.Ollama 65% 69% 260
CommunityToolkit.Aspire.Hosting.OpenTelemetryCollector 78% 61% 77
CommunityToolkit.Aspire.Hosting.PapercutSmtp 81% 50% 18
CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions 99% 89% 84
CommunityToolkit.Aspire.Hosting.Python.Extensions 45% 29% 100
CommunityToolkit.Aspire.Hosting.RavenDB 62% 48% 148
CommunityToolkit.Aspire.Hosting.Redis.Extensions 100% 71% 48
CommunityToolkit.Aspire.Hosting.Rust 94% 83% 16
CommunityToolkit.Aspire.Hosting.Solr 72% 100% 22
CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects 52% 49% 206
CommunityToolkit.Aspire.Hosting.Sqlite 89% 89% 52
CommunityToolkit.Aspire.Hosting.SqlServer.Extensions 100% 87% 78
CommunityToolkit.Aspire.Hosting.SurrealDb 55% 40% 256
CommunityToolkit.Aspire.KurrentDB 94% 92% 54
CommunityToolkit.Aspire.MassTransit.RabbitMQ 100% 100% 30
CommunityToolkit.Aspire.Meilisearch 97% 92% 68
CommunityToolkit.Aspire.Microsoft.Data.Sqlite 89% 85% 52
CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite 61% 58% 114
CommunityToolkit.Aspire.Minio.Client 90% 85% 112
CommunityToolkit.Aspire.OllamaSharp 77% 71% 132
CommunityToolkit.Aspire.RavenDB.Client 60% 53% 237
CommunityToolkit.Aspire.SurrealDb 79% 63% 78
Summary 68% (7209 / 10630) 56% (2064 / 3702) 4698

Minimum allowed line rate is 60%

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

This PR fixes a bug where the MCP Inspector integration fails when MCP servers expose only HTTPS endpoints. The fix enables HTTPS endpoint support while maintaining backward compatibility with HTTP-only servers.

  • Updates endpoint resolution logic to prefer HTTPS over HTTP with a fallback chain
  • Improves error messaging to reflect support for both HTTPS and HTTP endpoints
  • Adds comprehensive test coverage for HTTPS-only, HTTP-only, and mixed endpoint scenarios

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
src/CommunityToolkit.Aspire.Hosting.McpInspector/McpInspectorResource.cs Updated endpoint resolution to check for "https" first, then fall back to "http", following the pattern used in JavaScriptHostingExtensions.cs. Also updated error message to accurately reflect support for both endpoint types.
tests/CommunityToolkit.Aspire.Hosting.McpInspector.Tests/McpInspectorResourceBuilderExtensionsTests.cs Added three new test methods to verify HTTPS endpoint support, HTTPS preference when both endpoints exist, and proper endpoint selection behavior across different configurations.

// Arrange
var appBuilder = DistributedApplication.CreateBuilder();

// AddProject creates both http and https endpoints by default
Copy link

Copilot AI Nov 23, 2025

Choose a reason for hiding this comment

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

The comment states "AddProject creates both http and https endpoints by default", but this is inconsistent with the comment in the test above (line 450) which states "AddProject creates 'http' by default". This creates confusion about the actual behavior. Please verify the behavior and update comments consistently. Based on the code context, AddProject typically creates an HTTP endpoint by default, and HTTPS needs to be added explicitly with WithHttpsEndpoint().

Suggested change
// AddProject creates both http and https endpoints by default
// AddProject creates "http" endpoint by default

Copilot uses AI. Check for mistakes.
.WithHttpsEndpoint(name: "https");

// Act
var inspector = appBuilder.AddMcpInspector("inspector")
Copy link

Copilot AI Nov 23, 2025

Choose a reason for hiding this comment

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

Call to obsolete method AddMcpInspector.

Suggested change
var inspector = appBuilder.AddMcpInspector("inspector")
var inspector = appBuilder.AddMcpInspectorResource("inspector")

Copilot uses AI. Check for mistakes.
.WithHttpsEndpoint(name: "https");

// Act
var inspector = appBuilder.AddMcpInspector("inspector")
Copy link

Copilot AI Nov 23, 2025

Choose a reason for hiding this comment

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

Call to obsolete method AddMcpInspector.

Copilot uses AI. Check for mistakes.
var mockServer = appBuilder.AddProject<Projects.CommunityToolkit_Aspire_Hosting_McpInspector_McpServer>("mcpServer");

// Act
var inspector = appBuilder.AddMcpInspector("inspector")
Copy link

Copilot AI Nov 23, 2025

Choose a reason for hiding this comment

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

Call to obsolete method AddMcpInspector.

Copilot uses AI. Check for mistakes.
.WithHttpsEndpoint(name: "https");

// Act
var inspector = appBuilder.AddMcpInspector("inspector")
Copy link

Copilot AI Nov 23, 2025

Choose a reason for hiding this comment

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

This assignment to inspector is useless, since its value is never read.

Suggested change
var inspector = appBuilder.AddMcpInspector("inspector")
appBuilder.AddMcpInspector("inspector")

Copilot uses AI. Check for mistakes.
.WithHttpsEndpoint(name: "https");

// Act
var inspector = appBuilder.AddMcpInspector("inspector")
Copy link

Copilot AI Nov 23, 2025

Choose a reason for hiding this comment

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

This assignment to inspector is useless, since its value is never read.

Suggested change
var inspector = appBuilder.AddMcpInspector("inspector")
appBuilder.AddMcpInspector("inspector")

Copilot uses AI. Check for mistakes.
var mockServer = appBuilder.AddProject<Projects.CommunityToolkit_Aspire_Hosting_McpInspector_McpServer>("mcpServer");

// Act
var inspector = appBuilder.AddMcpInspector("inspector")
Copy link

Copilot AI Nov 23, 2025

Choose a reason for hiding this comment

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

This assignment to inspector is useless, since its value is never read.

Suggested change
var inspector = appBuilder.AddMcpInspector("inspector")
appBuilder.AddMcpInspector("inspector")

Copilot uses AI. Check for mistakes.
Copilot AI temporarily deployed to azure-artifacts November 23, 2025 03:21 Inactive
@aaronpowell aaronpowell merged commit b8e8bd8 into main Nov 23, 2025
114 checks passed
@aaronpowell aaronpowell deleted the copilot/fix-mcp-inspector-https branch November 23, 2025 06:11
@aaronpowell aaronpowell added this to the 13 milestone Nov 23, 2025
McpServerMetadata item = new(
mcpServer.Name,
mcpServer.GetEndpoint("http") ?? throw new InvalidOperationException($"The MCP server {mcpServer.Name} must have a 'http' endpoint defined."),
mcpServer.GetEndpoint("https") ?? mcpServer.GetEndpoint("http") ?? throw new InvalidOperationException($"The MCP server {mcpServer.Name} must have an 'https' or 'http' endpoint defined."),
Copy link
Contributor

Choose a reason for hiding this comment

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

This never returns null

Copy link
Member

Choose a reason for hiding this comment

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

What happens if there's no registered HTTPS endpoint though?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP Inspector does not work with https endpoint

3 participants