Table of Contents

Class HttpMcpServerBuilderExtensions

Namespace
Microsoft.Extensions.DependencyInjection
Assembly
ModelContextProtocol.AspNetCore.dll

Provides methods for configuring HTTP MCP servers via dependency injection.

public static class HttpMcpServerBuilderExtensions
Inheritance
HttpMcpServerBuilderExtensions
Inherited Members

Methods

WithHttpTransport(IMcpServerBuilder, Action<HttpServerTransportOptions>?)

Adds the services necessary for McpEndpointRouteBuilderExtensions.MapMcp to handle MCP requests and sessions using the MCP Streamable HTTP transport. For more information on configuring the underlying HTTP server to control things like port binding custom TLS certificates, see the Minimal APIs quick reference.

public static IMcpServerBuilder WithHttpTransport(this IMcpServerBuilder builder, Action<HttpServerTransportOptions>? configureOptions = null)

Parameters

builder IMcpServerBuilder

The builder instance.

configureOptions Action<HttpServerTransportOptions>

Configures options for the Streamable HTTP transport. This allows configuring per-session McpServerOptions and running logic before and after a session.

Returns

IMcpServerBuilder

The builder provided in builder.

Exceptions

ArgumentNullException

builder is null.