Protocol-driven adapter for stateless Streamable HTTP requests.
The default dialect is 2026-07-28. Explicitly enabled initialize-era dialects
share admission and execution. They run without HTTP sessions unless the
caller passes a Snodo.Session.Manager as the :sessions option of
prepare/3; see "Initialize-era sessions" below.
prepare/3 performs HTTP and mirrored-header admission without invoking an
application handler. execute/3 runs one prepared message through the shared
synchronous server core. This split lets HTTP servers admit a request before
submitting only application work to Snodo.Server.Executor.
Complete JSON responses and long-lived SSE descriptors are deliberately transport-server agnostic so Plug, Bandit, Cowboy, or a custom listener can translate them without changing protocol code.
Initialize-era sessions
With sessions: manager (a running Snodo.Session.Manager, or the
configuration Snodo.Session.Manager.config/1 returns) and auth: (the request's trusted auth value, or nil), requests
of the initialize-era dialects belong to a Snodo.Session:
- An
initializerequest starts a session.execute/3returns its ID in theMcp-Session-Idresponse header when initialization succeeds, and ends the session otherwise. At the manager's:max_sessionsthe request gets 503. Aninitializesent as a notification starts none. - Every later request, notification, and response must carry that header.
A missing header is 400. An unknown or expired ID, or a session bound to
a different principal, is 404 with JSON-RPC code -32001, and the client
initializes again. An
MCP-Protocol-Versionthat differs from the session's version is 400. - A JSON-RPC response object is routed to the server request waiting for
it and answered with 202. One without the header is accepted with 202,
as without sessions, unless its
MCP-Protocol-Versionnames an initialize-era version. DELETEends the session and is answered with 200.GETwithAccept: text/event-streamreturns{:standalone, session}. The caller opens the session's standalone stream withSnodo.Session.attach_stream/2(409 if it already has one).- During
execute/3, a handler's input requests are sent as server-to-client requests through the progress sink's owner, which receives{:mcp_stream_message, sink_reference, message}as aGenServer.call/3and replies:okonce the message is written on the request's event stream.
2026-07-28 requests are never part of a session. A GET or DELETE whose
MCP-Protocol-Version names a version without sessions gets 405, as
without sessions.
Summary
Functions
Executes one admitted request; transports may supply a cancellation token.
Runs admission and execution synchronously for embedding in another HTTP stack.
Admits and decodes one HTTP request without executing its MCP handler.
Types
@type prepare_result() :: {:ok, Snodo.Transport.StreamableHTTP.Prepared.t()} | {:response, Snodo.Transport.StreamableHTTP.Response.t()} | {:standalone, Snodo.Session.t()}
Functions
@spec execute( Snodo.Server.Runtime.t(), Snodo.Transport.StreamableHTTP.Prepared.t(), term() | nil ) :: Snodo.Transport.StreamableHTTP.Response.t() | Snodo.Transport.StreamableHTTP.StreamResponse.t()
Executes one admitted request; transports may supply a cancellation token.
@spec handle( Snodo.Server.Runtime.t(), Snodo.Transport.StreamableHTTP.Request.t(), keyword() ) :: Snodo.Transport.StreamableHTTP.Response.t() | Snodo.Transport.StreamableHTTP.StreamResponse.t()
Runs admission and execution synchronously for embedding in another HTTP stack.
A standalone GET stream cannot be served this way and is answered with 405.
@spec prepare( Snodo.Server.Runtime.t(), Snodo.Transport.StreamableHTTP.Request.t(), keyword() ) :: prepare_result()
Admits and decodes one HTTP request without executing its MCP handler.
Options are :allowed_origin_hosts, :allowed_hosts, and, for
initialize-era sessions, :sessions and :auth (see the module
documentation). {:standalone, session} is returned only with :sessions.