Skip to content

Stateless Transports & Multiplexing

The MCP client landscape currently contains two competing transport styles:

  1. Legacy Server-Sent Events (SSE): Traditional transport where the client opens a persistent GET stream and receives a session URL for subsequent POST requests.
  2. Streamable HTTP: Modern transport where client requests are atomic and self-contained over HTTP POST.

McpMultiplexerHandler inspects incoming HTTP requests and routes them to the appropriate SDK transport handler:

func (h *McpMultiplexerHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("X-Mcp-Force-Sse") == "true" {
h.sseHandler.ServeHTTP(w, r)
return
}
if r.Header.Get("Mcp-Session-Id") != "" || r.Method == "DELETE" || (r.Method == "POST" && !hasSessionID(r)) {
h.streamableHandler.ServeHTTP(w, r)
return
}
h.sseHandler.ServeHTTP(w, r)
}

When hosting on serverless platforms (Google Cloud Run, AWS ECS, Fly.io), containers scale to zero when idle and recycle frequently.

Configuring Stateless: true in StreamableHTTPOptions removes in-memory session dependencies:

  • Each POST request creates a temporary, self-contained transport.
  • Reconnected or restarted clients never encounter 404 session not found errors.
  • Container cold starts do not disrupt tool executions.