Skip to content
GenAI Figure

Technology UpdateAgentic AI

Stateless MCP servers on AWS AgentCore Runtime

AgentCore Runtime now supports MCP revision 2026-07-28, which removes protocol sessions. What stateless MCP means, how the runtime routes and checks such a server, and a small server you can run.

By Sritharan K (opens in a new tab)

Published Updated 10 min read

Cover card for the article Stateless MCP servers on AWS AgentCore Runtime

An MCP server behind a load balancer has an awkward property. Up to revision 2025-11-25, a Streamable HTTP client starts with an initialize handshake, and the server can hand out an Mcp-Session-Id that the client sends on every later request. A stateful server keeps what it knows about the client in that session, so every request has to reach the instance that holds it. Scaling out means sticky routing; a restart loses the state.

MCP revision 2026-07-28 removes the session from the protocol. Every request carries its own protocol version and client capabilities, so any instance can answer it. In November 2026 Amazon Bedrock AgentCore Runtime added support for that revision, with its own header for session routing and a recommended GET /ping health check.

The figure compares the two flows step by step: the session flow at the top, the stateless flow in the middle, and what AgentCore Runtime adds at the bottom.

Top: the 2025-11-25 flow, where initialize returns an Mcp-Session-Id and the state lives in one microVM. Middle: the 2026-07-28 flow, where create_basket returns a basket_id handle that add_item passes back to a backing store. Bottom: GET /ping and session routing in AgentCore Runtime.
The session flow of revision 2025-11-25 against the stateless flow of revision 2026-07-28, as AgentCore Runtime handles them. The basket_id is the one from the example run below.

What stateless MCP means#

The Key Changes page of revision 2026-07-28 lists nine major changes. I group the ones that make the protocol stateless into four:

  • No sessions. Mcp-Session-Id is gone, and tools/list, resources/list and prompts/list no longer vary per connection (SEP-2567).
  • No handshake. initialize is removed. Every request carries io.modelcontextprotocol/protocolVersion and io.modelcontextprotocol/clientCapabilities in _meta, and every server must implement a new server/discover method (SEP-2575).
  • No server-initiated requests. A server that needs sampling, elicitation or roots returns a result with resultType: "input_required", and the client retries the request with the answers: the Multi Round-Trip Requests pattern (SEP-2322).
  • No GET stream and no ping. Both are removed, as is SSE resumability. Change notifications use a subscriptions/listen request.

Stateless describes the protocol, not your application. A server that needs state across calls mints a handle, such as the basket_id that create_basket returns, and the client passes it back as an ordinary argument. The state lives in a store you run. SEP-2567 calls these explicit state handles (opens in a new tab): a tool-design pattern, not a wire format.

On HTTP, the transport copies body fields into headers so a gateway can route without parsing JSON: MCP-Protocol-Version, Mcp-Method, and Mcp-Name for tools/call, resources/read and prompts/get. A server must reject a mismatch with HTTP 400 and code -32020 (HeaderMismatch).

What AgentCore Runtime added#

The AgentCore release notes list "Support for MCP protocol version 2026-07-28" under November 2026, for MCP servers on both compute types, microVMs and Instances. The notes give the month, not a day, and the entry has no preview label. Clients on earlier versions are unaffected, and for 2025-11-25 and earlier both stateful and stateless mode stay supported.

The MCP protocol contract in the developer guide has the details:

  • Session routing. Requests with the same session ID still go to the same microVM, or the same instance session on Instances. For 2026-07-28 that ID comes from X-Amzn-Bedrock-AgentCore-Runtime-Session-Id. Mcp-Session-Id is still accepted and wins when a client sends both. With neither, the service generates an ID.
  • Health. The recommended GET /ping returns {"status": "Healthy"}, or HealthyBusy during background work so the session is not ended as idle. Without it, the runtime tries an MCP ping and then initialize. A 2026-07-28 server may reject both with 400, and the runtime then treats it as healthy unless it stops responding or returns server errors: a weak signal. Other error responses can fail the check.
  • Errors. For 2026-07-28 clients the HTTP status reflects the error, such as 429 for throttling and 404 for a missing resource, where older versions return 200 for most errors. The server's own 200, 202, 400, 401, 403 and 404 pass through; any other status becomes 424.

Why route by session at all? The contract names latency and cost, the active-session quota, and in-memory state such as the status of a long task. Stickiness is now a platform optimisation, not a protocol requirement.

Where it helps, and where not#

Useful:

  • Scale-out and restarts. A request that lands on a fresh microVM still finds its state through the handle.
  • Gateways and policy. Routing, rate limits and logs can use Mcp-Method and Mcp-Name without reading the body.
  • Elicitation and sampling. On 2025-11-25 AgentCore needs stateful mode for them; on 2026-07-28 they work in stateless mode. Sampling itself is now deprecated.

Not yet, or with care:

  • Clients. Older clients keep the session flow. Check which protocol version your MCP SDK sends.
  • State is your job. SEP-2567 advises checking the handle together with the caller's identity on every call, and, on a server without authentication, at least 128 bits of secure randomness per handle.
  • Deprecations. The same revision deprecates Roots, Sampling and Logging (SEP-2577).

Example: a stateless MCP server in Python#

The server below speaks revision 2026-07-28 over Streamable HTTP with the Python standard library only. It answers server/discover, tools/list and tools/call, checks the headers against the body, and serves GET /ping as AgentCore Runtime expects. Its two tools keep a basket in SQLite, keyed by a handle.

To show that no session is needed, I run two server processes with one shared database, and the client sends each request to the other instance. Tested with Python 3.12.14 on 28 November 2026. It leaves out SSE responses, subscriptions/listen, authentication and Base64 Mcp-Name decoding, and its handles are short for readability. Use an SDK for production.

basket_server.pypython
"""A stateless MCP server for protocol revision 2026-07-28, standard library only.

Cross-call state lives in SQLite, keyed by a handle the server mints. Any
instance can answer any request: no session, no initialize handshake.
"""
import json
import os
import sqlite3
import sys
import uuid
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer

VERSION = "2026-07-28"
SERVER_INFO = {"name": "basket-server", "version": "0.1.0"}
NAMED = {"tools/call", "resources/read", "prompts/get"}  # these need Mcp-Name
TOOLS = [
    {"name": "create_basket", "description": "Create an empty basket. Returns basket_id.",
     "inputSchema": {"type": "object", "additionalProperties": False}},
    {"name": "add_item", "description": "Add an item to the basket with this basket_id.",
     "inputSchema": {"type": "object", "required": ["basket_id", "item"],
                     "properties": {"basket_id": {"type": "string"},
                                    "item": {"type": "string"}}}},
]
TOOL_NAMES = {tool["name"] for tool in TOOLS}


def store():
    con = sqlite3.connect(os.environ.get("BASKET_DB", "baskets.db"))
    con.execute("CREATE TABLE IF NOT EXISTS items (basket TEXT, item TEXT)")
    return con


def structured(data):  # structured result plus the same JSON as text
    return {"content": [{"type": "text", "text": json.dumps(data)}],
            "structuredContent": data}


def call_tool(name, args):
    with store() as con:
        if name == "create_basket":
            # Short for the demo. Without auth, use 128 random bits (secrets module).
            basket = "b-" + uuid.uuid4().hex[:6]
            con.execute("INSERT INTO items VALUES (?, NULL)", (basket,))
            return structured({"basket_id": basket})
        basket = args.get("basket_id")
        known = con.execute("SELECT 1 FROM items WHERE basket = ?", (basket,)).fetchone()
        if not known or not args.get("item"):  # a tool error the model can fix
            return {"content": [{"type": "text", "text": "unknown basket_id or no item"}],
                    "isError": True}
        con.execute("INSERT INTO items VALUES (?, ?)", (basket, args["item"]))
        count = con.execute("SELECT COUNT(item) FROM items WHERE basket = ?",
                            (basket,)).fetchone()[0]
        return structured({"basket_id": basket, "items": count})


class Handler(BaseHTTPRequestHandler):
    def do_GET(self):
        if self.path == "/ping":  # AgentCore Runtime health check
            return self.reply(200, {"status": "Healthy"})
        self.reply(405, None)  # 2026-07-28 has no GET stream on /mcp

    do_DELETE = do_GET  # no session to delete either

    def do_POST(self):
        if self.path != "/mcp":
            return self.reply(404, None)
        if self.headers.get("Origin"):  # no browser clients for this server
            return self.reply(403, None)
        try:
            msg = json.loads(self.rfile.read(int(self.headers.get("Content-Length", 0))))
        except ValueError:
            return self.error(400, None, -32700, "Parse error")
        rid, method = msg.get("id"), msg.get("method")
        params = msg.get("params", {})
        version = params.get("_meta", {}).get("io.modelcontextprotocol/protocolVersion")
        # The body is the source of truth; the headers must be present and mirror it.
        sent = [self.headers.get("MCP-Protocol-Version"), self.headers.get("Mcp-Method")]
        body = [version, method]
        if method in NAMED:
            sent.append(self.headers.get("Mcp-Name"))
            body.append(params.get("name", params.get("uri")))
        if None in sent or sent != body:
            return self.error(400, rid, -32020, "Header mismatch")
        if version != VERSION:
            return self.error(400, rid, -32022, "Unsupported protocol version",
                              {"supported": [VERSION], "requested": version})
        if method == "server/discover":
            result = {"supportedVersions": [VERSION], "capabilities": {"tools": {}},
                      "ttlMs": 3600000, "cacheScope": "public"}
        elif method == "tools/list":
            result = {"tools": TOOLS, "ttlMs": 300000, "cacheScope": "public"}
        elif method == "tools/call" and params.get("name") in TOOL_NAMES:
            result = call_tool(params["name"], params.get("arguments", {}))
        elif method == "tools/call":
            return self.error(400, rid, -32602, f"Unknown tool: {params.get('name')}")
        else:
            return self.error(404, rid, -32601, "Method not found")
        result.update(resultType="complete",
                      _meta={"io.modelcontextprotocol/serverInfo": SERVER_INFO})
        self.reply(200, {"jsonrpc": "2.0", "id": rid, "result": result})

    def error(self, status, rid, code, message, data=None):
        err = {"code": code, "message": message, **({"data": data} if data else {})}
        self.reply(status, {"jsonrpc": "2.0", "id": rid, "error": err})

    def reply(self, status, body):
        raw = json.dumps(body).encode() if body is not None else b""
        self.send_response(status)
        self.send_header("Content-Type", "application/json")
        self.send_header("Content-Length", str(len(raw)))
        self.end_headers()
        self.wfile.write(raw)

    def log_message(self, *args):  # keep the demo output short
        pass


if __name__ == "__main__":
    host = os.environ.get("HOST", "127.0.0.1")  # AgentCore Runtime needs 0.0.0.0
    ThreadingHTTPServer((host, int(sys.argv[1])), Handler).serve_forever()

The client sets the headers and _meta by hand. The second-to-last call sends a wrong Mcp-Name on purpose.

basket_client.pypython
"""Calls two instances of basket_server.py in turn: one POST per request."""
import itertools
import json
import urllib.request
from urllib.error import HTTPError

VERSION = "2026-07-28"
INSTANCES = itertools.cycle(["http://127.0.0.1:8101", "http://127.0.0.1:8102"])
META = {"io.modelcontextprotocol/protocolVersion": VERSION,
        "io.modelcontextprotocol/clientInfo": {"name": "basket-client", "version": "0.1.0"},
        "io.modelcontextprotocol/clientCapabilities": {}}
ids = itertools.count(1)


def rpc(method, params=None, mcp_name=None):
    base = next(INSTANCES)
    params = {**(params or {}), "_meta": META}
    headers = {"Content-Type": "application/json",
               "Accept": "application/json, text/event-stream",
               "MCP-Protocol-Version": VERSION, "Mcp-Method": method}
    if "name" in params:
        headers["Mcp-Name"] = mcp_name or params["name"]
    body = {"jsonrpc": "2.0", "id": next(ids), "method": method, "params": params}
    request = urllib.request.Request(base + "/mcp", json.dumps(body).encode(), headers)
    try:
        with urllib.request.urlopen(request) as response:
            status, reply = response.status, json.load(response)
    except HTTPError as err:
        status, reply = err.code, json.load(err)
    label = f"{method} {params.get('name', '')}".strip()
    print(f"{base[-4:]}  {label:<24} {status}  ", end="")
    return reply


reply = rpc("server/discover")
print("versions", reply["result"]["supportedVersions"])
reply = rpc("tools/call", {"name": "create_basket", "arguments": {}})
basket = reply["result"]["structuredContent"]["basket_id"]
print(reply["result"]["content"][0]["text"])
for item in ["coffee", "milk"]:
    reply = rpc("tools/call", {"name": "add_item",
                               "arguments": {"basket_id": basket, "item": item}})
    print(reply["result"]["content"][0]["text"])
reply = rpc("tools/call", {"name": "add_item",
                           "arguments": {"basket_id": basket, "item": "tea"}},
            mcp_name="create_basket")
print(reply["error"]["code"], reply["error"]["message"])
base = next(INSTANCES)
with urllib.request.urlopen(base + "/ping") as response:
    print(f"{base[-4:]}  {'GET /ping':<24} {response.status}  {response.read().decode()}")

Run two instances and the client:

bash
python3.12 basket_server.py 8101 &
python3.12 basket_server.py 8102 &
python3.12 basket_client.py

The output, from the run on 28 November 2026. The basket_id is random:

text
8101  server/discover          200  versions ['2026-07-28']
8102  tools/call create_basket 200  {"basket_id": "b-129df3"}
8101  tools/call add_item      200  {"basket_id": "b-129df3", "items": 1}
8102  tools/call add_item      200  {"basket_id": "b-129df3", "items": 2}
8101  tools/call add_item      400  -32020 Header mismatch
8102  GET /ping                200  {"status": "Healthy"}

What to notice:

  • The basket survives the hop. It is created on 8102 and filled on 8101 and 8102. Neither process holds it in memory; the handle finds it in the store.
  • No handshake. The client never calls initialize. The server/discover call is optional.
  • Headers must match. The request whose Mcp-Name says create_basket while its body says add_item is refused with 400 and -32020 before any tool runs.

Deploying it on AgentCore Runtime#

For production, the developer guide uses the MCP Python SDK v2 (mcp>=2.3,<3), which supports 2026-07-28 and earlier versions. Its example server ends with the health route and run call below. I did not run it: it needs a package download and an AWS account.

my_mcp_server.py (excerpt)python
# Recommended: health check endpoint for AgentCore Runtime
@mcp.custom_route("/ping", methods=["GET"])
async def ping(request: Request) -> JSONResponse:
    return JSONResponse({"status": "Healthy"})

if __name__ == "__main__":
    mcp.run(transport="streamable-http", host="0.0.0.0", port=8000, stateless_http=True)

From the same guide:

  • stateless_http=True only affects clients on 2025-11-25 and earlier; 2026-07-28 is always stateless.
  • Set protocolConfiguration.serverProtocol to MCP, or the runtime treats the server as plain HTTP, without JSON-RPC error responses. The AgentCore CLI does it with agentcore add runtime --protocol MCP, then agentcore build and agentcore deploy.
  • For related requests on one microVM, the client sends the same X-Amzn-Bedrock-AgentCore-Runtime-Session-Id on each.

Pros, cons and limits#

AspectDetails
ProsAny instance answers any request. No handshake. Headers that gateways can route on. Older clients keep working.
ConsCross-call state moves into a store you build and secure. Clients must support 2026-07-28. Reliable health checks need /ping.
LimitsStickiness still matters for latency, cost and the session quota. The release notes give the month only.
Lock-inThe protocol is open. The session header, /ping body and error mapping are AgentCore specific.

When to choose it#

Build new MCP servers for AgentCore Runtime on revision 2026-07-28 when your clients support it, and design cross-call state as explicit handles from the start. Keep stateless_http=True for older clients, and add GET /ping either way, because the fallback health check is weak for a 2026-07-28 server.

Next step: follow Deploy MCP servers in AgentCore Runtime (opens in a new tab), then read the session and health sections of the MCP protocol contract (opens in a new tab) before you put a gateway or load balancer in front of the server.

References

  1. Release notes for Amazon Bedrock AgentCore (November 2026: Support for MCP protocol version 2026-07-28) (opens in a new tab). Amazon Web Services, 2026-11.
  2. MCP protocol contract (Amazon Bedrock AgentCore Developer Guide) (opens in a new tab). Amazon Web Services.
  3. Key Changes in MCP specification revision 2026-07-28 (opens in a new tab). Model Context Protocol.
  4. Streamable HTTP transport, MCP specification revision 2026-07-28 (opens in a new tab). Model Context Protocol.