OptionaloncloseCallback for when the connection is closed for any reason.
This should be invoked when close() is called as well.
OptionalonerrorCallback for when an error occurs.
Note that errors are not necessarily fatal; they are used for reporting any kind of exceptional condition out of band.
OptionalonmessageCallback for when a message (request or response) is received over the connection.
Includes the requestInfo and authInfo if the transport is authenticated.
The requestInfo can be used to get the original request information (headers, etc.)
OptionalsessionThe session ID generated for this connection.
Closes the connection.
Close an SSE stream for a specific request, triggering client reconnection. Use this to implement polling behavior during long-running operations - client will reconnect after the retry interval specified in the priming event.
Close the standalone GET SSE stream, triggering client reconnection.
Use this to implement polling behavior for server-initiated notifications.
Handles an incoming HTTP request, whether GET, POST, or DELETE
Returns a Response object (Web Standard)
Optionaloptions: HandleRequestOptionsSends a JSON-RPC message (request or response).
If present, relatedRequestId is used to indicate to the transport which incoming request to associate this outgoing message with.
Optionaloptions: { relatedRequestId?: RequestId }Sets the supported protocol versions for header validation.
Called by the server during connect() to pass its supported versions.
Starts the transport. This is required by the Transport interface but is a no-op
for the Streamable HTTP transport as connections are managed per-request.
Server transport for Web Standards Streamable HTTP: this implements the MCP Streamable HTTP transport specification using Web Standard APIs (
Request,Response,ReadableStream).This transport works on any runtime that supports Web Standards: Node.js 18+, Cloudflare Workers, Deno, Bun, etc.
In stateful mode:
404 Not Found400 Bad RequestIn stateless mode:
Example: Stateful setup
Example: Stateless setup
Example: Hono.js
Example: Cloudflare Workers