Enum HttpServerSessionMode
- Namespace
- ModelContextProtocol.AspNetCore
- Assembly
- ModelContextProtocol.AspNetCore.dll
Specifies how the Streamable HTTP transport tracks state between requests.
public enum HttpServerSessionMode
Fields
Stateful = 1The server tracks a long-lived session for every client, which requires session affinity.
Requests using the
2026-07-28or later protocol revision are refused with a-32022 UnsupportedProtocolVersionerror so that a dual-path client downgrades to theinitializehandshake and obtains the session the server was configured to provide. Use StatefulForInitializeClients to serve those clients natively instead of forcing a downgrade.StatefulForInitializeClients = 2The server tracks a long-lived session for clients that use the
initializehandshake and serves clients using the2026-07-28or later protocol revision statelessly on the same endpoint.This hybrid mode allows an application to adopt the latest protocol revision progressively rather than waiting for every client to migrate. Clients using the
2025-11-25or earlier revisions get a full stateful session with anMcp-Session-Idand continue to use the GET and DELETE endpoints, while clients using the2026-07-28or later revisions are served per request with no session ID minted or echoed, and receive405 Method Not Allowedfor GET and DELETE, exactly as in Stateless mode.Because a
2026-07-28request has no session, the session-only features listed on Stateless remain unavailable to those clients even though other clients on the same endpoint have sessions. ConfigureSessionOptions is invoked once per session forinitialize-handshake clients and once per request for2026-07-28and later clients.Stateless = 0The server never tracks state between requests, allowing for load balancing without session affinity.
SessionId is null, the
Mcp-Session-Idheader is unused, RunSessionHandler and ConfigureSessionOptions are invoked once per request, and the GET, DELETE, and/sseendpoints are unavailable. Unsolicited server-to-client messages and all server-to-client requests are unsupported because any response might arrive at another ASP.NET Core application process. Client sampling, elicitation, and roots capabilities are disabled because the server cannot make requests; use Multi Round-Trip Requests (MRTR) instead.
Remarks
Starting with the 2026-07-28 protocol revision, Streamable HTTP no longer supports sessions
(SEP-2567 removed Mcp-Session-Id, and SEP-2575 removed the initialize handshake), so requests
using that revision or later can only ever be served statelessly. This enumeration allows specification for
how the server reconciles that requirement with clients that still rely on the initialize handshake.