Callback for when the connection is closed for any reason.
This should be invoked when close() is called as well.
Sets callback for when the transport is closed.
Callback 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.
Sets callback for transport errors.
Callback 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.)
Sets callback for incoming messages.
Gets the session ID for this transport instance.
Closes the transport and all active connections.
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 or POST.
This method converts Node.js HTTP objects to Web Standard Request/Response
and delegates to the underlying WebStandardStreamableHTTPServerTransport.
Node.js IncomingMessage, optionally with auth property from middleware
Node.js ServerResponse
OptionalparsedBody: unknownOptional pre-parsed body from body-parser middleware
Sends a JSON-RPC message through the transport.
Optionaloptions: { relatedRequestId?: RequestId }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 Streamable HTTP: this implements the MCP Streamable HTTP transport specification. It supports both SSE streaming and direct HTTP responses.
This is a wrapper around
WebStandardStreamableHTTPServerTransportthat provides Node.js HTTP compatibility. It uses the@hono/node-serverlibrary to convert between Node.js HTTP and Web Standard APIs.In stateful mode:
404 Not Found400 Bad RequestIn stateless mode:
Example: Stateful setup
Example: Stateless setup
Example: Using with a pre-parsed request body (e.g. Express)