Streamable HTTP Transport in MCP: Architecture
Build remote multi-client MCP servers using unified Streamable HTTP (/mcp) transport. Covers per-request metadata, stateless mode, subscriptions/listen, and reverse proxy configs.
Generate & Validate Multi-Client MCP Config
One-click export with environment variables & path locators for Claude Desktop, Cursor, Windsurf, and OpenAI Codex CLI.
Streamable HTTP Transport in MCP: Remote Multi-Client Architecture
Earlier MCP implementations used the now-deprecated HTTP+SSE transport: a long-lived event stream for server messages plus a separate HTTP POST endpoint for client requests. Paths such as /sse and /messages?sessionId=... were choices made by SDK examples, not names mandated by the specification. See the archived Multi-Client SSE guide. In production cloud deployments, that two-channel topology suffered from sticky-session load balancer drops, double-hop cold start latency, and inability to scale to zero on serverless runtimes.
The modern MCP transport specification standardizes remote communication around Streamable HTTP (StreamableHTTPServerTransport and WebStandardStreamableHTTPServerTransport). Streamable HTTP puts every JSON-RPC message on a single HTTP endpoint (/mcp). Important: revision 2026-07-28 removed protocol-level sessions, the Mcp-Session-Id header, and the standalone GET /mcp stream. Those mechanisms belonged to 2025-03-26 through 2025-11-25 and are described below only as legacy compatibility. See the official changelog (opens in a new tab) and Streamable HTTP spec (opens in a new tab).
1. Architectural Evolution: Legacy SSE vs. Unified Streamable HTTP
Under Streamable HTTP, a server exposes a single URI path (typically /mcp) that accepts POST requests. GET and DELETE to that path were part of older revisions and are no longer part of the core protocol:
Core Protocol Mechanics
- ▸Unified
POST /mcpDispatch: Every client JSON-RPC request is its ownHTTP POSTto/mcp. The client must sendAccept: application/json, text/event-stream, plus theMCP-Protocol-Version,Mcp-Method, and (where applicable)Mcp-Nameheaders that mirror fields in the body. The body's_meta.io.modelcontextprotocol/*fields are the source of truth. - ▸Per-request JSON or SSE response: A fast call returns
application/json; a long-running call may returnContent-Type: text/event-streamcarrying request-scoped notifications followed by the final response, on that same HTTP transaction. - ▸No sessions; explicit subscriptions: Revision
2026-07-28removedinitialize,Mcp-Session-Id, and the standaloneGET /mcpstream. Long-lived change notifications are obtained with asubscriptions/listenPOST whose response is a long-lived SSE stream. Cancellation of a Streamable HTTP request is signalled by closing its response stream. (spec (opens in a new tab))
2. Prerequisites & Package Matrix
| Component | Example version baseline (not a hard minimum) | Recommended version | Purpose |
|---|---|---|---|
| Node.js | v20.18.0 LTS | v22.12.0 LTS | Server runtime with native Web Streams |
@modelcontextprotocol/server + @modelcontextprotocol/node + @modelcontextprotocol/express | 2.x | Latest 2.x | Official TypeScript SDK v2 packages, which implement the 2026-07-28 spec; the older @modelcontextprotocol/sdk (opens in a new tab) v1 line supports only versions through 2025-11-25 |
| Express | 4.21+ | Latest 4.x | HTTP routing and DNS-rebinding protection via createMcpExpressApp |
| Zod | 4.2.0 | 4.2.0+ | Tool input schema validation (zod/v4) |
Install the current dependencies:
npm install @modelcontextprotocol/server @modelcontextprotocol/node @modelcontextprotocol/express express zod
npm install -D typescript @types/express @types/node tsx3. Production TypeScript Implementation (createMcpHandler)
Below is a stateless Streamable HTTP server for the current (2026-07-28) transport: one POST endpoint at /mcp, no session map, and no GET/DELETE handlers. createMcpHandler builds a fresh server for every request and validates the mirrored request headers itself, returning 400 Bad Request with -32020 HeaderMismatch on a mismatch (header rules (opens in a new tab)); createMcpExpressApp adds JSON parsing and Host/Origin checks for DNS-rebinding defense:
// server-streamable-http.ts
import { createMcpExpressApp } from "@modelcontextprotocol/express";
import { toNodeHandler } from "@modelcontextprotocol/node";
import { createMcpHandler, McpServer } from "@modelcontextprotocol/server";
import * as z from "zod/v4";
const handler = createMcpHandler(() => {
const server = new McpServer({
name: "enterprise-streamable-mcp",
version: "2.0.0",
});
server.registerTool(
"inspect_service_health",
{
description: "Check latency and connection pool metrics for an internal microservice.",
inputSchema: z.object({
serviceName: z.string().min(1).describe("Target microservice identifier"),
environment: z.enum(["production", "staging"]).default("production"),
}),
},
async ({ serviceName, environment }) => ({
content: [
{
type: "text",
text: JSON.stringify({
service: serviceName,
environment,
status: "healthy",
timestamp: new Date().toISOString(),
}),
},
],
})
);
return server;
});
const app = createMcpExpressApp();
// Every JSON-RPC message is its own POST /mcp. No session, no GET/DELETE.
const nodeHandler = toNodeHandler(handler);
app.all("/mcp", (req, res) => void nodeHandler(req, res, req.body));
const PORT = Number(process.env.PORT || 3001);
app.listen(PORT, "127.0.0.1", () => {
console.error(`Streamable HTTP MCP Server listening at http://127.0.0.1:${PORT}/mcp`);
});This uses the v2 SDK entry point that speaks 2026-07-28. The older
@modelcontextprotocol/sdk v1 packages (through 1.32.2) implement only protocol
versions up to 2025-11-25; their StreamableHTTPServerTransport does not emit
2026-era results (SDK README (opens in a new tab),
v2 migration guide (opens in a new tab)).
4. Multi-Host Client Configuration (url Schema)
Configure modern MCP clients with the url key pointing at the Streamable HTTP endpoint; do not use an endpoint property.
OpenAI Codex CLI (~/.codex/config.toml)
[mcp_servers.remote_ops]
url = "https://mcp.internal.example.com/mcp"
bearer_token_env_var = "MCP_OPS_BEARER_TOKEN"Cursor (.cursor/mcp.json) and other JSON clients accepting url
{
"mcpServers": {
"remote-ops": {
"url": "https://mcp.internal.example.com/mcp",
"headers": {
"Authorization": "Bearer ${MCP_OPS_BEARER_TOKEN}"
}
}
}
}5. Reverse Proxy & CORS Hardening
1. CORS for browser clients
Browser-based hosts must be allowed to send Accept, Content-Type, MCP-Protocol-Version, Mcp-Method, and Mcp-Name. Under 2026-07-28 there is no Mcp-Session-Id response header to expose, so Access-Control-Expose-Headers no longer needs to list one; older clients that still send session headers must be handled by a compatibility layer. See the spec's security section (opens in a new tab).
2. Nginx Non-Buffered Location Block
When a Streamable HTTP response upgrades to text/event-stream for long-running progress updates, disable proxy chunk buffering:
location /mcp {
proxy_pass http://127.0.0.1:3001/mcp;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
proxy_cache off;
proxy_read_timeout 300s;
}proxy_read_timeout is the nginx directive; a bare read_timeout line is not valid nginx configuration. The spec also recommends that servers set X-Accel-Buffering: no on SSE responses so intermediaries do not buffer events (spec (opens in a new tab)).
3. Origin Validation & DNS Rebinding Defense
Local or internal Streamable HTTP servers listening on loopback interfaces (127.0.0.1) are vulnerable to DNS rebinding attacks if a malicious webpage issues cross-origin POST /mcp requests from a developer's browser. Always enforce two server-side middleware checks before routing requests to the MCP handler (createMcpHandler, or StreamableHTTPServerTransport in v1):
- ▸Strict
OriginHeader Allowlist: Reject any request carrying anOriginheader that does not explicitly match your approved web host origins withHTTP 403 Forbidden. - ▸Host Header Binding: Verify the HTTP
Hostheader matches your expected domain orlocalhost:<port>, and bind local development servers exclusively to127.0.0.1rather than0.0.0.0.
6. Stateless Serverless Mode (Cloudflare Workers & AWS Lambda)
Revision 2026-07-28 makes stateless operation the default protocol shape: createMcpHandler (or WebStandardStreamableHTTPServerTransport on v1 for legacy revisions) builds a fresh server instance per request. Every POST /mcp request instantiates a request-scoped handler, processes the JSON-RPC frame, returns the response, and releases memory. Compare this with the legacy stateful transport (still needed only to interoperate with 2025-03-26–2025-11-25 clients):
| Operational Property | Legacy stateful (Mcp-Session-Id, ≤ 2025-11-25) | Current (2026-07-28, no sessions) |
|---|---|---|
| Load Balancing | Requires session affinity or shared Redis event bus | Standard round-robin across any edge node or pod |
| Server-Initiated Notifications | Long-lived GET /mcp SSE stream | subscriptions/listen POST stream; request-scoped notifications stay on their own response |
| Scale-to-Zero Serverless | Difficult due to persistent memory sockets | Native fit for Cloudflare Workers, AWS Lambda, Cloud Run |
| Memory Footprint | Scales linearly with concurrent sessions | Constant per active in-flight HTTP request |
Troubleshooting Streamable HTTP Regressions
- ▸
400 Bad Requestwith-32020 HeaderMismatch: TheMCP-Protocol-Version,Mcp-Method, orMcp-Nameheader does not match the JSON-RPC body. Recent revisions require those mirrored headers on every POST; see server validation (opens in a new tab). - ▸
400 Bad Requestwith-32022 UnsupportedProtocolVersion: The server does not support the requested version; retry using a version from the error'ssupportedarray. - ▸A broken SSE stream:
2026-07-28removedLast-Event-IDresumability. Re-issue the request with a new request ID rather than trying to replay a lost stream. There is no session to re-initialize.
External References
Build your full agent toolstack in the Visual Generator
Combine MCP servers with databases, search APIs, and memory graphs in a single configuration file.
Did this setup guide work with your AI host?
Help test this configuration across Claude, Cursor, and Codex CLI. Be the first to report:
Streamable HTTP Transport in MCP: Architecture FAQ
Why do browser MCP clients get HTTP 400 on their second Streamable HTTP request?
Browser CORS policies hide custom response headers from client JavaScript unless explicitly exposed. Your server must send 'Access-Control-Expose-Headers: Mcp-Session-Id' so the client can read the session ID returned by 'initialize' and attach it to subsequent POST /mcp requests.
Can Streamable HTTP MCP servers run on serverless platforms like Cloudflare Workers?
Yes. Using 'WebStandardStreamableHTTPServerTransport' in stateless mode (setting 'sessionIdGenerator: undefined'), each POST /mcp request is handled independently without in-memory sticky sessions, allowing true scale-to-zero edge deployment.
What happened to the 'endpoint' field in client MCP configurations?
Early 2025 clients used an 'endpoint' key for legacy SSE URLs. Modern MCP clients (Claude Desktop, Cursor, OpenAI Codex CLI) standardize on the 'url' key pointing directly to the unified '/mcp' Streamable HTTP route.
Written by Rad Tome
Independent maintainer, MCP Codex
Specializing in Model Context Protocol (MCP) integrations, autonomous AI agent orchestration, and distributed developer toolchains. Researches and benchmarks production MCP client-server architectures across OpenAI Codex, Claude, and Cursor.
Related Guides
Email Automation MCP: Gmail and Resend Workflows
Orchestrate Gmail and Resend email workflows using MCP. Full config.toml, domain whitelisting, draft queues, tool schemas, and security troubleshooting.
CommunicationSlack MCP Server Setup for Codex and Claude
Integrate Slack with OpenAI Codex and Claude Desktop via MCP. Full config.toml, bot token OAuth scopes, tool references, and thread reply patterns.