Skip to content

Commit 15488e7

Browse files
committed
Changing how the API surfaces info
1 parent 1bf8189 commit 15488e7

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

src/CommunityToolkit.Aspire.Hosting.McpInspector/McpInspectorResource.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,25 @@ public class McpInspectorResource(string name) : ExecutableResource(name, "npx",
1515
/// </summary>
1616
public const string ClientEndpointName = "client";
1717

18+
private EndpointReference? _clientEndpoint;
19+
20+
/// <summary>
21+
/// Gets the client endpoint reference for the MCP Inspector.
22+
/// </summary>
23+
public EndpointReference ClientEndpoint => _clientEndpoint ??= new(this, ClientEndpointName);
24+
1825
/// <summary>
1926
/// The name of the server proxy endpoint.
2027
/// </summary>
2128
public const string ServerProxyEndpointName = "server-proxy";
2229

30+
private EndpointReference? _serverProxyEndpoint;
31+
32+
/// <summary>
33+
/// Gets the server proxy endpoint reference for the MCP Inspector.
34+
/// </summary>
35+
public EndpointReference ServerProxyEndpoint => _serverProxyEndpoint ??= new(this, ServerProxyEndpointName);
36+
2337
/// <summary>
2438
/// Gets the version of the MCP Inspector.
2539
/// </summary>

src/CommunityToolkit.Aspire.Hosting.McpInspector/McpInspectorResourceBuilderExtensions.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,28 @@ public static class McpInspectorResourceBuilderExtensions
1212
/// </summary>
1313
/// <param name="builder">The <see cref="IDistributedApplicationBuilder"/> to which the MCP Inspector resource will be added.</param>
1414
/// <param name="name">The name of the MCP Inspector container resource.</param>
15-
public static IResourceBuilder<McpInspectorResource> AddMcpInspector(this IDistributedApplicationBuilder builder, [ResourceName] string name)
15+
/// <param name="clientPort">The port for the client application. Defaults to 6274.</param>
16+
/// <param name="serverPort">The port for the server proxy application. Defaults to 6277.</param>
17+
public static IResourceBuilder<McpInspectorResource> AddMcpInspector(this IDistributedApplicationBuilder builder, [ResourceName] string name, int clientPort = 6274, int serverPort = 6277)
1618
{
1719
var resource = builder.AddResource(new McpInspectorResource(name))
1820
.WithArgs(["-y", $"@modelcontextprotocol/inspector@{McpInspectorResource.InspectorVersion}"])
1921
.ExcludeFromManifest()
20-
.WithHttpEndpoint(isProxied: false, port: Random.Shared.Next(3000, 4000), env: "CLIENT_PORT", name: McpInspectorResource.ClientEndpointName)
21-
.WithHttpEndpoint(isProxied: false, port: Random.Shared.Next(4000, 5000), env: "SERVER_PORT", name: McpInspectorResource.ServerProxyEndpointName)
22+
.WithHttpEndpoint(isProxied: false, port: clientPort, env: "CLIENT_PORT", name: McpInspectorResource.ClientEndpointName)
23+
.WithHttpEndpoint(isProxied: false, port: serverPort, env: "SERVER_PORT", name: McpInspectorResource.ServerProxyEndpointName)
2224
.WithEnvironment("DANGEROUSLY_OMIT_AUTH", "true")
2325
.WithHttpHealthCheck("/", endpointName: McpInspectorResource.ClientEndpointName)
24-
.WithHttpHealthCheck("/config", endpointName: McpInspectorResource.ServerProxyEndpointName);
26+
.WithHttpHealthCheck("/config", endpointName: McpInspectorResource.ServerProxyEndpointName)
27+
.WithUrlForEndpoint(McpInspectorResource.ClientEndpointName, annotation =>
28+
{
29+
annotation.DisplayText = "Client";
30+
annotation.DisplayOrder = 2;
31+
})
32+
.WithUrlForEndpoint(McpInspectorResource.ServerProxyEndpointName, annotation =>
33+
{
34+
annotation.DisplayText = "Server Proxy";
35+
annotation.DisplayOrder = 1;
36+
});
2537

2638
builder.Eventing.Subscribe<BeforeResourceStartedEvent>(resource.Resource, async (@event, ct) =>
2739
{

0 commit comments

Comments
 (0)