McpServerResourceBuilderExtensions Methods
Class Methods 1 member
Provides extension methods for configuring MCP (Model Context Protocol) server endpoints on resources.
WithMcpServer(IResourceBuilder<T>, string?, string?) Section titled WithMcpServer(IResourceBuilder<T>, string?, string?) extension IResourceBuilder<T> Marks the resource as hosting a Model Context Protocol (MCP) server on the specified endpoint.
public static class McpServerResourceBuilderExtensions{ public static IResourceBuilder<T> WithMcpServer<T>( this IResourceBuilder<T> builder, string? path = "/mcp", string? endpointName = null) { // ... }}Parameters
builder IResourceBuilder<T> The resource builder. path string? optional An optional path to append to the endpoint URL when forming the MCP server address. Defaults to "/mcp". endpointName string? optional An optional name of the endpoint that hosts the MCP server. If not specified, defaults to the first HTTPS or HTTP endpoint. Returns
IResourceBuilder<T> A reference to the ApplicationModel.IResourceBuilder`1 for chaining additional configuration. Remarks
This method adds an
McpServerEndpointAnnotation to the resource, enabling the Aspire tooling to discover and proxy the MCP server exposed by the resource. Examples
Mark a resource as hosting an MCP server using the default endpoint: Mark a resource as hosting an MCP server with a custom path and endpoint: var api = builder.AddProject<Projects.MyApi>("api") .WithMcpServer("/sse", endpointName: "https");
var api = builder.AddProject<Projects.MyApi>("api") .WithMcpServer();