expectedwrong hindsight

An MCP Server That Lives in a Durable Object Is the Right Shape

The stateful edge is where agents want to run, and someone already figured that out.

2 min read 266 words #mcp #cloudflare #agents #durable-objects #infrastructure
hindsight — still happening

MCP in a Durable Object is still the right shape. Stateful protocols need stateful infrastructure. The insight was correct the week it was written.

MCP is three months old and someone already put it inside a Durable Object.

The repo is cf-mcp-durable-object by gingerhendrix — an MCP server running on Cloudflare's edge, with each session backed by a Durable Object. The thing that makes this interesting is not the Cloudflare part. It's that whoever built this immediately understood what MCP actually is.

MCP is a stateful protocol. Each session maintains context across tool calls — the server knows who's connected, what's been asked, what tools are in scope. That's not a REST API. That's a persistent conversation with a process. And if you try to run it on stateless infrastructure, you immediately start fighting the infrastructure — pinned sessions, sticky load balancers, Redis for shared state, the whole apology tour.

Durable Objects give you a single-instance, single-threaded process per session, guaranteed to run in one place, hibernatable when idle, addressable by a stable ID. It's what you'd design if you knew ahead of time that sessions were the unit of work. Which is exactly what MCP sessions are.

The cynical reading is that this is a toy, a proof of concept, something for a blog post. The less cynical reading is that this is what the infrastructure layer for agentic systems looks like — not a monolith, not a fleet of workers fighting over shared state, but one Durable Object per agent session, each one owning its context, running at the edge closest to wherever the agent happens to be talking from.

Three months in and someone already drew the right diagram. Nobody planned this.

That's usually how it goes.