How to Migrate an MCP Server to the Stateless Spec: Sessions, Streams and Client Registration

The 2026-07-28 revision of the Model Context Protocol removes protocol-level sessions and the Mcp-Session-Id header, drops the initialize handshake and ends resumable SSE streams. A server that keeps state under a session ID, reads client capabilities from the handshake or replays missed events with Last-Event-ID has to change. The Python and TypeScript v2 SDKs serve old and new clients side by side, so you can migrate in steps.
MCP is the protocol AI applications use to call tools and read data on a server. This guide is for people who already run one, built against the 2025 spec, and want to know what breaks, where the state goes and which dates matter. If you are still deciding which MCP servers your staff may connect at all, start with rolling out Claude Code safely.
What does the 2026-07-28 revision change for a server?
The changelog lists nine major changes since 2025-11-25. Five of them hit a typical tool server hardest:
- No sessions. The changelog says to “Remove protocol-level sessions and the
Mcp-Session-Idheader from the Streamable HTTP transport.” List endpoints no longer vary per connection. - No handshake. The
initializeandnotifications/initializedexchange is gone. Every request carries its protocol version and the client’s capabilities in_meta, and a version your server does not support returnsUnsupportedProtocolVersionError. - Discovery is mandatory. Servers MUST implement
server/discover, which returns supported versions, capabilities and identity. Clients may skip it. - No resumable streams. The changelog removes
Last-Event-IDand SSE event IDs: “A broken response stream loses the in-flight request; clients MUST re-issue it as a new request with a new request ID.” The HTTP GET endpoint is replaced bysubscriptions/listen. - No server-to-client requests. Sampling, elicitation and roots requests are no longer sent as separate requests. The server returns an
input_requiredresult and the client retries the original call with its answers (Multi Round-Trip Requests, MRTR).
On 5 December 2026 there is no later revision. The versioning page names 2026-07-28 as the current version, and the draft changelog holds two small items so far, one of them a bump of the referenced Client ID Metadata Document draft from -00 to -03. The release-cycle post of 11 November 2026 targets 2027-03-30 for the next one.
How do you find what in your server depends on a session?
Search your code for the session ID first, then for anything that behaves differently between two connections to the same server. The spec removed per-connection variation from list endpoints, so a tool set, cache or default tied to a connection is now wrong by definition. Seven places to check:
- Session-keyed state. Grep for
Mcp-Session-Idand for the session ID your SDK exposes. In the v1 TypeScript SDK that isctx.sessionIdorextra.sessionId. Anything stored under it counts: a selected project, an open transaction, a cached auth context. - Per-connection tool lists. If
tools/listreturns different tools depending on who connected first or what they did, move that difference into authorization or into tool arguments. - Replay logic. Any buffer keyed by event ID, and any code that reads
Last-Event-ID, is dead code. The question that replaces it: what happens to a long tool call when the stream drops? The client now re-sends it as a new request, so the call must tolerate running twice. - Handshake assumptions. Code that reads client capabilities once at
initializeand stores them has to read them from each request. Client identity is only a SHOULD: clients “SHOULD identify themselves on each request”. - Server-initiated requests. A tool that pauses to ask the user, or asks the client’s model for a completion, over a held-open stream no longer works: servers MUST NOT send independent requests on the response stream. Rewrite it as an
input_requiredresult. Roots, Sampling and Logging are also deprecated. - Log notifications.
logging/setLevelandpingare removed. A server “MUST NOT emitnotifications/messagefor requests that did not include” the per-requestio.modelcontextprotocol/logLevelfield. Clients that do not set it will see your logs stop. - Gateways and proxies. Every POST must now carry
MCP-Protocol-VersionandMcp-Method, plusMcp-Namefortools/call,resources/readandprompts/get. A header that does not match the body must be rejected with400and error code-32020(HeaderMismatch). A WAF rule that strips unknown headers will break this, and you can drop sticky-session routing once your clients have moved.
The header rules are in the Streamable HTTP page, the log-level rule in the changelog.
Where does the state go when there is no session?
Into something the caller names explicitly. The changelog’s answer: “Servers that need cross-call state use explicit, server-minted handles passed as ordinary tool arguments.” Your server creates the state, returns an identifier, and the model passes the identifier back on later calls. The state itself sits in your own store, keyed by that handle.
The maintainers’ release post of 28 July 2026 says the same in plainer words: “Dropping the protocol-level session doesn’t force your application to be stateless. If your server needs to carry state across calls, mint an explicit handle from a tool and have the model pass it back as an argument.” Their reason: it works better than session state hidden in the transport, because the model can see the handle and thread it between tools.
Our rules for the handle, from how we would build it, not from the spec:
- Treat it as untrusted input. Look it up on every call and bind it to the authenticated caller, so a handle from one user is useless to another.
- Make it opaque, unguessable and short-lived, with an expiry you enforce.
- Return a plain error for an unknown or expired handle, so the model starts the flow again instead of guessing.
A handle is a bearer credential that the model carries around. The reasoning in why stolen tokens beat prompts as an attack on agents applies to it unchanged.
A second mechanism covers questions inside a single call. With MRTR the server returns requestState, an opaque string the client echoes on the retry. The TypeScript SDK migration guide says it “round-trips through the client and is therefore untrusted input” and that its codec is “signed, not encrypted”, so the client can read the payload. Do not put secrets in it.
Old behaviour, new behaviour: what changes in your server?
Ten changes, each with the edit it asks of you. The left column is the 2025-11-25 behaviour, the middle the 2026-07-28 behaviour.
| Topic | 2025-11-25 | 2026-07-28 | What to change |
|---|---|---|---|
| Session | Server may assign Mcp-Session-Id, ended with HTTP DELETE | No protocol-level sessions | Move state to handles and your own store. Answer DELETE with 405, ignore the header, never mint or echo an ID. |
| Handshake | initialize then notifications/initialized | Version and capabilities in _meta on every request | Read capabilities per request. Return UnsupportedProtocolVersionError with the versions you support. |
| Discovery | Handshake result | server/discover, mandatory for servers | Implement it, or let the SDK do it. |
| Dropped stream | Resume with Last-Event-ID | Request is lost, client re-sends with a new ID | Delete the replay buffer. Make slow tool calls safe to run twice. |
| Change notifications | Standalone GET stream | subscriptions/listen, opt-in per type | Answer GET with 405. Implement listen if you send list-changed notices. |
| Questions to the user | Server sends elicitation or sampling requests on the stream | input_required result, client retries | Rewrite mid-call questions as MRTR rounds. |
| Routing | Body only | Mcp-Method and Mcp-Name headers required | Allow the headers through the proxy. Reject mismatches with 400 and -32020. |
| Caching | No freshness fields | ttlMs and cacheScope required on list and read results | Set a TTL per result. Return tools in a stable order. |
| Logging | logging/setLevel | Level in _meta per request, off if absent | Use OpenTelemetry, or stderr on stdio, as the deprecation note suggests. |
| Client registration | Dynamic Client Registration | Client ID Metadata Documents preferred, DCR deprecated | If you run the authorization server, support metadata documents and keep DCR as the fallback. |
Sources for the rows: the changelog, the Streamable HTTP page for the 405 and header handling, and the client registration page. That page tells clients to use pre-registered credentials first, Client ID Metadata Documents if the authorization server advertises client_id_metadata_document_supported, and Dynamic Client Registration as the fallback.
How do you serve old and new clients during the move?
Run both on one endpoint. The spec lets a server support both eras, and it matters: in the spec’s compatibility matrix a client that only speaks the 2025 handshake fails against a server that only speaks the new revision. A modern-only server should answer old traffic in defined ways: 405 for GET or DELETE, ignore Mcp-Session-Id (“do not mint or echo session IDs”) and ignore Last-Event-ID. Do not switch to modern-only until you know your clients have moved.
The Python SDK made this the default. Its v2.0.0 release of 28 July 2026 “supports the 2026-07-28 revision of the Model Context Protocol and serves every earlier revision from the same server.” The decorator API is unchanged and FastMCP is now MCPServer. The 1.x line is in maintenance mode, and the notes suggest mcp>=1.28,<2 if you are not ready.
In TypeScript the v2 packages are @modelcontextprotocol/server and its siblings. The migration guide warns that for a hand-constructed Client, Server or McpServer, “Nothing in v2 puts a 2026-07-28 byte on the wire by default”, so the HTTP entry point is createMcpHandler. It serves 2026-07-28 per request and, by default, 2025-era traffic per request too, statelessly. Adapted from the guide:
import { createMcpHandler, McpServer } from '@modelcontextprotocol/server';
const handler = createMcpHandler(() => {
const server = new McpServer({ name: 'my-server', version: '1.0.0' }, { capabilities: { tools: {} } });
// register tools/resources/prompts once, the same factory backs both eras
return server;
});If your existing server is sessionful and 2025 clients still depend on that, the guide keeps your old handler for them and routes by request shape:
const modern = createMcpHandler(factory, { legacy: 'reject' });
export default {
async fetch(request: Request) {
if (await isLegacyRequest(request)) return myExistingLegacyHandler(request);
return modern.fetch(request);
}
};The release post lists the Go and C# SDKs as speaking 2026-07-28 too; we did not read their release notes. Latest TypeScript release we read: 2.4.0 on 23 October 2026.
What do you gain, and what does it cost?
The gain is operational. The release post: “Any request can now land on any server instance behind a plain round-robin load balancer without needing shared storage.” List results carry ttlMs and cacheScope (“public” or “private”), which says whether a shared intermediary may cache the response. The changelog also asks servers to return tools in a deterministic order “to enable client-side caching and improve LLM prompt cache hit rates.” And the routing headers mean, in the maintainers’ words, that “Your gateway, rate limiter, or WAF can route and meter on those headers instead of parsing JSON bodies.”
The cost lands on flows that leaned on a session. The maintainers say it themselves: “there will be some migration cost, especially for developers that did depend on session identifiers”. Wizards, mid-call questions and anything with a “current project” become explicit handles or MRTR rounds.
In our view the trade is fair for a server that is mostly stateless tools, and a real rewrite for one that is a conversation. The state does not vanish. It moves into your own store and into the model’s context, which means a store lookup per call and a credential in the prompt. The load balancer stops needing shared storage; your application may start needing it.
Which deadlines apply?
Deprecated does not mean removed. The lifecycle policy sets a minimum twelve-month window, and removal is a Core Maintainer decision during release preparation. The deprecated features registry lists what is on the clock:
| Feature | Deprecated in | Earliest removal | Migrate to |
|---|---|---|---|
| Dynamic Client Registration | 2026-07-28 | First revision released on or after 2027-07-28 | Client ID Metadata Documents |
| Roots, Sampling, Logging | 2026-07-28 | First revision released on or after 2027-07-28 | Tool parameters, provider APIs, stderr or OpenTelemetry |
| HTTP+SSE transport | 2025-03-26 | “Three months after SEP-2596 reaches Final” | Streamable HTTP |
Two points need care. First, the HTTP+SSE row conflicts with the announcement, which calls it deprecated “with a year-long offramp”. The registry and the policy proposal give three months, and neither page states a calendar date for it. We would not plan around a year. Second, sessions, the handshake and resumability are not deprecated. They are gone from the new revision, and a server that still speaks the 2025 revisions keeps working for clients that do too.
The release-cycle post says specification releases are generally published on “the last Tuesday of March and September”, with 2027-03-30 next. By that schedule the first release on or after 28 July 2027 would be the September one. That is our arithmetic, not a published date, and the maintainers may remove a feature later than its earliest date or not at all.
What should you do this month?
- Inventory session use: every read of
Mcp-Session-Id, every store keyed by a session ID, everyLast-Event-IDreader. Write down what each one is for. - Pin your current SDK below v2 if you must, then try the v2 line on a branch. In Python that is
mcp2.x, in TypeScript the@modelcontextprotocol/serverpackages. - Put the dual-era endpoint behind your gateway and test an old and a new client against it.
- Replace each session-keyed value with a handle you validate, bind to the caller and expire.
- Rewrite mid-call questions as MRTR rounds, and treat
requestStateas untrusted input. - Check your authorization server: does it support Client ID Metadata Documents, and what happens to clients that registered dynamically?
Do this today
Search your server code for Mcp-Session-Id and for your SDK’s session ID accessor, and write down every place that stores something under it.
Related reading
- How to Roll Out Claude Code in a Company Without Losing Control
- How to Find the AI Agents Your Staff Already Run
- Your AI Agent Gets Hijacked by Stolen Tokens, Not Prompts
- AI Agent Orchestration: What Breaks in Production
- Web Access for AI Agents Needs a Write-Action Allowlist
Sources: MCP specification 2026-07-28, changelog, Streamable HTTP and versioning and compatibility; MCP blog, The 2026-07-28 Specification; MCP blog, A More Predictable Release Cycle; Python SDK v2.0.0 release notes; TypeScript SDK migration guide.
Frequently Asked Questions
Does a server built on the 2025 MCP spec stop working?
Not by itself. In the spec's compatibility matrix a server that speaks only the 2025 revisions keeps working for clients that fall back to the initialize handshake, and fails for clients that speak only the new revision. A dual-era server answers both, which is why the Python and TypeScript v2 SDKs serve old and new clients from one endpoint.
Where does state go once Mcp-Session-Id is gone?
Into explicit handles. The changelog says servers that need cross-call state use server-minted handles passed as ordinary tool arguments, and the maintainers' release post says to mint a handle from a tool and have the model pass it back as an argument. The state itself sits in your own store, keyed by the handle. Validate the handle on every call, bind it to the caller and expire it.
When is Dynamic Client Registration removed from MCP?
Not before the first revision released on or after 2027-07-28, according to the deprecated features registry. Removal is a Core Maintainer decision at release preparation and can come later or not at all. Dynamic Client Registration stays available for authorization servers that do not support Client ID Metadata Documents.