Yuval Avidani
Author
The MCP protocol, the one that connects AI models to our tools and our data, just went through the biggest change since it was born. In version 2026-07-28, it became stateless. No more "handshake" at the start of the conversation, no more session ID, and every request arrives at the server with everything it needs to know, baked right in. The official MCP blog calls this "the biggest release since launch," and honestly, they're right.
At the same time, in those same weeks, Earendil shipped Pi 1.0 with MCP built in, after months of saying they wouldn't support it at all. The way they pulled it off is called Codemode, and in my eyes these two stories are really one story: the protocol is growing up, turning from a toy that runs on our laptop into infrastructure you can actually put in production.
In this guide we'll build, from scratch, a small MCP server on the new spec, migrate an old server to it, and figure out why any of this matters. We'll follow one example the whole way through: a server called ticket-desk, which lets an AI agent search support tickets in our helpdesk system.
Let's start from zero: what even is MCP
MCP (Model Context Protocol) is an open language that defines one shared standard for how an AI app talks to external tools and data sources — for anyone who wants to connect a model to their systems without writing a separate integration for each one. Anthropic introduced the protocol at the end of 2024, and since then it's become the standard that almost every serious AI tool speaks.
The official docs use an analogy that's hard to beat: the protocol is like a USB-C port for AI apps. There used to be a different cable for every device, and the drawer was full of cables. Today there's one port, and any device that speaks USB-C plugs into any computer that speaks USB-C. Same thing here: one MCP server we write will work with Claude, with Cursor, with Pi, and with any Client (the app that runs the model) that speaks the protocol.
Let's break down the basic terms, because we'll be using them constantly:
- An MCP server is a small piece of software that exposes capabilities. In our case, that's ticket-desk.
- A Tool is an action the model can ask to run, like lookup-ticket, which takes a ticket ID and returns its status.
- Transport is "the road" the messages travel on: either stdio, meaning direct communication with software running on the same machine, or HTTP, when the server lives in the cloud.
How big is this, really? According to the official blog, even before this release the official SDKs were already hitting "nearly half a billion downloads a month," and both the TypeScript SDK and the Python SDK crossed a billion downloads total.
The problem: a server that remembers everyone who ever talked to it
Up through the previous version (2025-11-25), every conversation with an MCP server opened with a fixed ritual. The client sent an initialize message ("Hi, I'm Claude, I speak this version and support these capabilities"), the server replied, and the client confirmed with an initialized message. On remote servers, the server also issued a session ID in a header called Mcp-Session-Id, and from that point on the client had to attach it to every single request.
Think of it like a waiter at a restaurant. In the old world, we sit down, tell the waiter we're vegetarian and allergic to nuts, and from that moment only he can serve us, because only he remembers. If he goes home in the middle of the meal, we start over from scratch.
That's exactly what ticket-desk looked like in the old version. In the official code from the SDK v1 README, the server keeps a Map of all sessions in memory, and on every request it checks: is there a session ID? Do I recognize it? If not, and this isn't an initialize request, the request gets rejected:
Why sessions kill scale. As long as the server runs on our own laptop, this doesn't bother anyone. The problem starts the moment you want to put ticket-desk into production, serving thousands of users. For that you run several copies of the server, and in front of them you put a Load Balancer, a component that distributes requests across the copies — like a hostess seating guests among several waiters.
And now watch what happens: the first request lands on copy A, and it saves the session in its own memory. The second request lands on copy B, which has no idea what that session ID is and rejects it. Turns out there were only two solutions, and both of them hurt:
- Sticky Sessions: teach the load balancer to always route the same client to the same copy. Works, but if that copy goes down, all its sessions go down with it.
- A shared session store: put Redis or a database in the middle, and every copy checks there. Works, but now we've got another component to maintain, and another point of failure.
And that's before we even get to Serverless-style setups, like Vercel or Cloudflare Workers, where every request can run on a completely different machine and there's no "memory" between requests at all. To be fair, the old approach wasn't dumb: a bidirectional protocol with sessions let the server push messages to the client whenever it wanted, which is genuinely convenient. It's just that the infrastructure cost turned out to be too high.
The fix: every request carries its own full context
The new spec solves this in a way that's almost embarrassingly simple. According to the official changelog, both sessions at the protocol level and the Mcp-Session-Id header were removed, and so was the initialize handshake. Instead of telling the server once who we are and hoping it remembers, every request carries the protocol version and the client's capabilities with it, in a field called _meta.
Back to the restaurant: now every order comes with a note attached, "vegetarian, no nuts." Any waiter can pick it up, and any waiter can go home without anyone noticing. That's literally what the official blog says: every request can land on any copy of the server, behind a dead-simple Round Robin load balancer, with no shared storage needed at all.
A few more important changes that come along with this:
- The server/discover call: a new call every server must implement, where it publishes which versions it supports, what it can do, and its name. The client can ask this upfront, instead of going through the opening ritual.
- State that needs to survive between calls moves out into the open: the server issues a "Handle," its own ID, and the model passes it along as a regular parameter to the next tool call. Like an order number we read out over the phone, instead of expecting the operator to just remember us.
- The ping and logging/setLevel messages are gone, and the log level is now sent separately with every single request.
- Multi-Round-Trip Requests (MRTR): if a tool needs more info from the user mid-task, the server returns an intermediate result, and the client resends the original request with the answer attached.
Hands-on: building ticket-desk and migrating an old server
Now for the fun part. The official TypeScript SDK shipped as version 2 alongside the new spec, on July 28, 2026 (on npm, the current version as I'm writing this is 2.3.1). The single @modelcontextprotocol/sdk package split into separate packages for server and client, and the Node adapter now lives in its own package. You'll need Node 20+ and Zod 4.2+.
The heart of the new server is a function called createMcpHandler. It takes a "Factory," a function that builds a server, and runs it fresh for every single HTTP request. Per the docs, it holds nothing between requests, which is exactly why a v2 server is stateless and scales horizontally by default. Here's the full ticket-desk we actually ran:
Notice what's missing from this code, and this is the genuinely exciting part: no session map, no randomUUID, no initialize check, and no session cleanup when the connection closes. The two lines with validateHost and validateOrigin aren't decoration — the docs require them to protect against an attack called DNS Rebinding, where a malicious website tries to talk to a server running locally on our own machine.
When we ran the server and sent a tool call, the response came back with no Mcp-Session-Id header at all, with resultType: "complete" (a field every result must now carry) and with the server's name tucked inside _meta. And here's a bonus we checked ourselves: that exact same server also answered an old-style initialize request under version 2025-11-25, which means clients that haven't upgraded yet keep right on working. According to the SDK's protocol versions page, that's by design: createMcpHandler serves both generations from the same endpoint.
One more detail worth knowing: in the new version, an HTTP request has to carry both an MCP-Protocol-Version header and the version inside the body. When we sent a request without the header, the server came back with an explicit error that the headers and body disagree. The client-side SDK handles this automatically, but anyone writing a manual client will run into it fast.
The migration: how to move an old server over. If you already have a server out there, there's a clear path. The SDK's official migration guide starts with an automated tool (a Codemod, a script that rewrites code based on rules), and after that there's a small amount of manual work left. Here's what that looked like for ticket-desk:
In plain words: you run the official codemod, swap the old package for the new ones and bump Zod to version 4, turn every server.tool into registerTool with a config object, and delete all the session-management code in favor of createMcpHandler. If your code was leaning on the session ID to remember something, this is the moment to turn that piece of info into an explicit handle that gets passed as a parameter. At the end, run tsc --noEmit and your tests.
And on timing: the new spec adopted, for the first time, an official feature lifecycle policy, with a minimum 12-month window between the moment a feature gets marked Deprecated and the moment it's actually allowed to be removed. In this release, Roots, Sampling, Logging, and the old HTTP+SSE transport all got marked this way. Per the official blog they'll "continue to work for at least 12 months," but new implementations shouldn't be adopting them. In other words: no need to panic, but the clock is running.
The second trend, Code Mode: when the agent writes code instead of clicking buttons
Now for the second trend. Say our agent needs to go through 200 tickets in ticket-desk and find the ones where the customer is angry. The normal way, it calls the tool, gets all that text dumped into the context window (the model's temporary working memory for the conversation), calls the tool again, and so on. Every call costs tokens, and every intermediate result has to pass through the model.
Code Mode takes a different approach entirely: instead of calling tools one at a time, the model writes a short piece of code that calls the tools, filters and combines the results, and runs it inside a Sandbox, a locked-down environment where the code can't touch anything it's not allowed to. Only the final result comes back to the model. Think of it like the difference between dictating every single step to your assistant versus just handing her one to-do list.
Cloudflare called this Code Mode, and in November 2025 Anthropic published an engineering writeup on "running code with MCP," with an example where token usage dropped from 150,000 to 2,000 — a 98.7% savings. Worth being precise here: that's one example of theirs, not an average. And in that same writeup they also warn that running code this way requires an isolated environment, resource limits, and monitoring.
And what about Pi? On September 29, 2026, Earendil published a post called "You Said No MCP!", which racked up 687 points on Hacker News. They admit that in the past they trashed MCP on podcasts and in posts, and explain that the world changed and MCP got better. Their solution is Codemode: a JavaScript sandbox that runs inside the Harness (the wrapper that runs the model), letting the agent combine tool calls in code and choose the order to run them in. On October 1, Pi 1.0 shipped with Codemode and built-in MCP support.
My take: what this means for us, and what's still unsolved
In my eyes, these two moves complete each other. The stateless spec turns an MCP server into a plain HTTP service, the kind any DevOps team already knows how to deploy, scale, and monitor. And Code Mode handles the other side of the same problem: how does an agent use dozens of tools without choking its own context window.
Bottom line for anyone building today: new server, write straight on SDK v2. Existing server, plan a migration for the coming quarter, especially if it's running behind a load balancer. And check whether your clients already support this: Anthropic announced that support for the new version is "rolling out" across Claude products, without a fixed date per product.
And it's worth being honest about the limits here too. State didn't disappear, it just moved from the protocol up into the app: now we're the ones responsible for handles, for requests that are safe to run twice without side effects (Idempotency), and for retries. Stream resumption on a dropped connection also got removed from the transport layer, and a request that gets cut off mid-stream simply gets resent from scratch. And if you built something on Sampling or Roots, you need to start planning a transition, even with a year on the clock.
So, which MCP server of ours do we migrate to the new spec first — and what are we going to discover when we do?
Want to go deeper with this?
I break down the whole world of MCP, Skills, and connecting Claude to our tools without writing a single line of code, in depth, in my course Practical AI with Claude, in Hebrew. And for anyone who wants to build agents and servers themselves from the terminal, there's Claude Code Mastery, in English.
I post the demos, including MCP servers I build live on stream, to YouTube and LinkedIn. You can also follow along on X, on Instagram and on TikTok, and I share the code on GitHub.
So, which MCP server of yours would benefit the most from no longer having to remember anyone?
