Blue request cards, each carrying a yellow state token, travel independently toward three red server blocks in a textured screen print
All posts

Stateless MCP: migrating off Mcp-Session-Id (2026-07-28 spec)

MCP 2026-07-28 removes initialize and Mcp-Session-Id. Where session state goes now, how an old client fails against a modern server, and how to keep a server reachable from an AIVAX gateway.

In February, a public MCP server for French open data started answering Session not found as soon as its operators added workers. The Mcp-Session-Id it had issued lived in the memory of one worker, the client's next request landed on another, and the maintainers answered by configuring sticky sessions. A server that follows MCP 2026-07-28 has no protocol session to lose that way. The revision, released on July 28, 2026, removes the initialize handshake and the Mcp-Session-Id header (SEP-2575, SEP-2567), and every request now says what it needs, so any instance that can authenticate the caller can serve it.

"Stateless" describes the protocol. Your application still has a cart, a half-finished import or a browser tab to remember, and the changelog says that servers needing cross-call state use explicit, server-minted handles passed as ordinary tool arguments. What goes away is a transport that remembers for you, so each piece of continuity becomes a decision in your own API.

Each request carries what the handshake used to establish

Revisions 2025-03-26 through 2025-11-25 opened with initialize and could hand back an Mcp-Session-Id that the client had to repeat. A server that required it answered requests without it with 400 Bad Request and an expired session with 404 Not Found, as the 2025-11-25 transport spec describes. Running such a server meant tying that identifier to a process or rebuilding the session from shared storage, and sticky routing and session draining followed from that.

In 2026-07-28 the request carries io.modelcontextprotocol/protocolVersion and io.modelcontextprotocol/clientCapabilities in _meta; clients should add clientInfo, and servers should answer with serverInfo in each result's _meta. On Streamable HTTP the version is mirrored in MCP-Protocol-Version, the method in Mcp-Method, and the tool, prompt or resource name in Mcp-Name. A tools/call that carries its own state handle looks like this:

POST /mcp HTTP/1.1
Content-Type: application/json
MCP-Protocol-Version: 2026-07-28
Mcp-Method: tools/call
Mcp-Name: add_to_cart

{
  "jsonrpc": "2.0",
  "id": 7,
  "method": "tools/call",
  "params": {
    "_meta": {
      "io.modelcontextprotocol/protocolVersion": "2026-07-28",
      "io.modelcontextprotocol/clientInfo": { "name": "ExampleClient", "version": "1.0.0" },
      "io.modelcontextprotocol/clientCapabilities": {}
    },
    "name": "add_to_cart",
    "arguments": { "cart_id": "cart_8f3a", "sku": "TEE-M-BLK", "quantity": 1 }
  }
}

Servers must implement server/discover to advertise their versions, capabilities and identity, but clients may skip it: they can send the real request and handle UnsupportedProtocolVersionError if the version is wrong. The standalone GET stream gives way to subscriptions/listen, a long-lived POST response stream that clients opt into.

MCP session state moves from the transport into explicit application handles The left side shows three calls tied by a hidden session to one server instance. The right side shows self-contained calls routed to different instances, each carrying the same explicit application handle to durable application state. Earlier Streamable HTTP MCP 2026-07-28 Transport session creates instance affinity Request data makes application state portable call 1 · session S7 transport-held context call 2 · session S7 transport-held context call 3 · session S7 transport-held context server instance A owns session S7 instance B cannot help Sticky routing or shared session recovery self-contained call 1 handle: workflow-42 self-contained call 2 handle: workflow-42 self-contained call 3 handle: workflow-42 server instance A server instance B server instance C durable application state
Earlier revisions could bind continuity to a transport session and one server instance. In 2026-07-28, requests can reach different instances because the caller carries an explicit handle and the application resolves it against durable state.

State moves into handles your server mints

When a tool needs continuity, the server returns a handle (a cart ID, a workflow ID, a cursor) and the caller passes it back in later arguments. Any instance can resolve it against durable storage, so a round-robin load balancer works and a dead instance takes no protocol session with it. Sticky routing remains available if your own code keeps per-client state in instance memory. Cloudflare draws the same line: an ordinary Worker can serve stateless MCP, and Durable Objects stay the right primitive when the application itself needs coordinated state.

A handle becomes part of your interface, and its security is yours to design. Scope each one to the caller's identity and tenant so nobody can guess or reuse another tenant's, give it an expiry, and decide whether the model sees it or the host injects it. If I were starting this migration, I would begin by grepping for state keyed by Mcp-Session-Id or assumed to exist after initialize, since replacing those with handles and storage is the one step that changes your data model.

A broken stream loses the request, so writes need an operation key

The new revision removes SSE event IDs and Last-Event-ID. If a response stream breaks, the in-flight request is lost, and the changelog requires the client to re-issue it as a new request with a new request ID. The server cannot assume the first attempt never ran: the side effect may have committed before the connection dropped.

A read-only tool survives that. A tool that deploys, sends a message or charges an account needs an operation key minted by the caller, claimed together with the write and mapped to a stored result, which is the pattern in idempotent tool calls. Log the original request ID, the replacement ID and the operation key together, or nobody will be able to reconstruct what happened.

When a server needs input in the middle of a request, it uses the Multi Round-Trip Requests pattern: it returns resultType: "input_required" with inputRequests, an opaque requestState, or both, and the client retries the original method under a new request ID, echoing requestState unchanged. I would treat requestState like a session cookie, because the spec tells servers to treat it as attacker-controlled input: protect its integrity with an HMAC or AEAD and bind it to the principal, a short expiry and the originating request. Even then it is not single-use, so a one-time redemption needs its own server-side guard.

Tasks and MCP Apps are extensions, so decide what happens without them

Holding an HTTP response open is a poor way to run a job that can outlive a client, a proxy timeout or a deployment. The Tasks extension, io.modelcontextprotocol/tasks, lets a server answer tools/call with a task handle when the client advertised the capability. The client polls tasks/get at the server's pollIntervalMs, supplies requested input with tasks/update, and asks for cancellation with tasks/cancel, which is cooperative and does not guarantee a cancelled end state. Clients must persist task IDs if the work should outlive them, and the server needs a task store with retention and tenant scoping. The C# SDK notes that its v2 implementation has no wire compatibility with the experimental tasks of its v1.3 and v1.4 releases.

The spec says that when one side lacks an extension, the other must revert to core behavior or reject the request with an appropriate error. For a job that deploys or charges, I would reject: a synchronous answer that hides a still-running job misleads the model into reporting success.

MCP Apps is the second extension, and it lets a server ship interactive HTML that the host renders in a sandboxed iframe. That HTML is third-party code even when its tool is read-only, so a host that adds the extension takes on the sandbox, the content security policy and the consent prompt.

Anything in front of your server has to validate headers and key its cache

Mcp-Method is required on every Streamable HTTP POST, and Mcp-Name on tools/call, resources/read and prompts/get, so a proxy can route and rate-limit without parsing JSON. The body stays authoritative: a server that reads it must reject a mismatch with 400 Bad Request and JSON-RPC error -32020 (HeaderMismatch), per the server validation rules. If your edge routes or authorizes on Mcp-Name, check first that MCP-Protocol-Version names a revision that enforces that validation, because a caller can otherwise present an allowed tool in the header and send a different one in the body. Tool schemas can also mirror chosen parameters into Mcp-Param-{Name} headers with x-mcp-header, which is how an edge routes on a region or tenant value without reading the payload.

List results now carry ttlMs and cacheScope. If your tool list differs by user, mark it "private": a shared cache keyed on the URL alone would otherwise serve one tenant's catalog to another. Return tools in a stable order too, since a reshuffled list defeats client caches and provider prompt caches, and the token cost of a large catalog is paid on every request.

Authorization changed in the same revision. Clients validate iss when the authorization response includes one (RFC 9207), key stored credentials by the issuing authorization server and must re-register when that server changes, and Dynamic Client Registration is deprecated in favor of Client ID Metadata Documents. For anyone who stores tokens on behalf of users, that means a credential table keyed by issuer, and "we forward a bearer token" no longer describes a complete design. The checklist in how to safely connect third-party MCP servers covers the review around it.

A modern-only server answers an old client with 400

The spec publishes a compatibility matrix. A modern client against a modern server works, and so does a dual-era client against either kind: on Streamable HTTP it sends a modern request first, and on a 400 Bad Request it reads the body. A recognized modern JSON-RPC error means the server is modern, so the client retries with a version the server advertises; anything else means the server is legacy and the client falls back to initialize.

Two pairings fail. A legacy client against a modern-only server sends a request without the required headers, gets 400 Bad Request, and has no way to fall forward. A modern client against a legacy server fails the other way: a legacy server that insists on a session rejects a request that has none, so the client may see a "Mcp-Session-Id header is required" error. The spec's matrix adds that such a server may also stay silent or process an ambiguous method under legacy semantics, and the message text is whatever that implementation writes. A dual-era client recovers by falling back to initialize; a modern-only client has to be pointed at a different server.

A modern-only server should name the versions it supports in any error it returns to initialize, since that message may be the only thing a legacy user sees. It should answer an HTTP GET or DELETE to the endpoint with 405 Method Not Allowed, ignore an Mcp-Session-Id header without minting or echoing one, and ignore Last-Event-ID.

My recommendation is to run a dual-era endpoint during the migration. The spec lets one endpoint serve both eras concurrently, choosing by how the client opens: a request with per-request _meta is served statelessly, and an initialize request selects legacy semantics for that session. Retire the legacy branch when the counts of initialize requests, requests carrying Mcp-Session-Id, and GET streams reach zero. SDK support decides how much of this you write yourself: the C# SDK's v2 line implements 2026-07-28 and uses the legacy handshake automatically when it meets a down-level server, and the TypeScript SDK has a guide for adopting the revision.

Making a server reachable from an AIVAX gateway

An AI Gateway takes external Streamable HTTP servers as tool sources: it lists their tools, exposes them to the model as functions, and sends the remote call when the model picks one, as the MCP tool-source documentation describes. A source can carry headers, which are sent on every connection, and a cacheDuration that sets how long discovered tools are reused (600 seconds by default, from 0 to 86400). Tool calls themselves are never cached.

The gateway's MCP client opens each connection with the initialize handshake and does not implement server/discover (the MCP documentation lists it as unsupported), so a server that accepts only the stateless 2026-07-28 flow cannot be a gateway tool source. The client also authenticates with the static headers you configure on the source and runs no OAuth flow, so the token in headers is one you issue and rotate yourself. The URL you register should be the dual-era endpoint from the previous section, where modern clients get stateless handling and the gateway gets its handshake. If your server is modern-only, I would put a dual-era route in front of it for the gateway's connections and keep the stateless route for everything else. Remote skill discovery follows the same flow, and MCP skills vs tools covers that extension.

Write the server as if every tool call arrives on a fresh connection, because nothing held by a transport session carries from one call to the next. The application handle goes in the tool arguments, or the server resolves it from the metadata that AIVAX adds to each call under _meta: _aiv_external_user_id, _aiv_call_source, _aiv_conversation_token, _aiv_moment, _aiv_nonce, and any custom metadata from the request or session. The conversation token can be null, AIVAX generates one for chat completions when the request sends none, and the docs say it is neither a credential nor a unique call ID. Validate the user and tenant against your own records before acting on any of these values, and check the nonce against your configured hook key as hook authentication describes.

Results come back to the model as text, image and audio content blocks plus structured content. For a job that takes minutes, return a job ID and give the model a second tool that reports its status; the job ID travels in your own arguments, and a retry that reuses the same operation key finds the first attempt's result.

Checked against the docs and implementation on November 17, 2026.