Class HttpServerTransportOptions
- Namespace
- ModelContextProtocol.AspNetCore
- Assembly
- ModelContextProtocol.AspNetCore.dll
Configuration options for McpEndpointRouteBuilderExtensions.MapMcp. which implements the Streaming HTTP transport for the Model Context Protocol. See the protocol specification for details on the Streamable HTTP transport. https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http
public class HttpServerTransportOptions
- Inheritance
-
HttpServerTransportOptions
- Inherited Members
Properties
ConfigureSessionOptions
Gets or sets an optional asynchronous callback to configure per-session McpServerOptions with access to the HttpContext of the request that initiated the session.
public Func<HttpContext, McpServerOptions, CancellationToken, Task>? ConfigureSessionOptions { get; set; }
Property Value
IdleTimeout
Gets or sets the duration of time the server will wait between any active requests before timing out an MCP session.
public TimeSpan IdleTimeout { get; set; }
Property Value
Remarks
This is checked in background every 5 seconds. A client trying to resume a session will receive a 404 status code and should restart their session. A client can keep their session open by keeping a GET request open. Defaults to 2 hours.
MaxIdleSessionCount
Gets or sets maximum number of idle sessions to track in memory. This is used to limit the number of sessions that can be idle at once.
public int MaxIdleSessionCount { get; set; }
Property Value
Remarks
Past this limit, the server will log a critical error and terminate the oldest idle sessions even if they have not reached their IdleTimeout until the idle session count is below this limit. Clients that keep their session open by keeping a GET request open will not count towards this limit. Defaults to 100,000 sessions.
RunSessionHandler
Gets or sets an optional asynchronous callback for running new MCP sessions manually. This is useful for running logic before a sessions starts and after it completes.
public Func<HttpContext, IMcpServer, CancellationToken, Task>? RunSessionHandler { get; set; }
Property Value
Stateless
Gets or sets whether the server should run in a stateless mode that does not require all requests for a given session to arrive to the same ASP.NET Core application process.
public bool Stateless { get; set; }
Property Value
Remarks
If true, the "/sse" endpoint will be disabled, and client information will be round-tripped as part of the "mcp-session-id" header instead of stored in memory. Unsolicited server-to-client messages and all server-to-client requests are also unsupported, because any responses may arrive at another ASP.NET Core application process. Client sampling and roots capabilities are also disabled in stateless mode, because the server cannot make requests. Defaults to false.
TimeProvider
Used for testing the IdleTimeout.
public TimeProvider TimeProvider { get; set; }