Skip to content

Support SSE part of the Streamable HTTP Specification #76

@sdelamo

Description

@sdelamo

https://modelcontextprotocol.io/specification/2025-06-18/basic/transports#streamable-http

If the server initiates an SSE stream:
The SSE stream SHOULD eventually include JSON-RPC response for the JSON-RPC request sent in the POST body.
The server MAY send JSON-RPC requests and notifications before sending the JSON-RPC response. These messages SHOULD relate to the originating client request.
The server SHOULD NOT close the SSE stream before sending the JSON-RPC response for the received JSON-RPC request, unless the session expires.
After the JSON-RPC response has been sent, the server SHOULD close the SSE stream.
Disconnection MAY occur at any time (e.g., due to network conditions). Therefore:
Disconnection SHOULD NOT be interpreted as the client cancelling its request.
To cancel, the client SHOULD explicitly send an MCP CancelledNotification.
To avoid message loss due to disconnection, the server MAY make the stream resumable.

Listening for Messages from the Server

The client MAY issue an HTTP GET to the MCP endpoint. This can be used to open an SSE stream, allowing the server to communicate to the client, without the client first sending data via HTTP POST.
The client MUST include an Accept header, listing text/event-stream as a supported content type.
The server MUST either return Content-Type: text/event-stream in response to this HTTP GET, or else return HTTP 405 Method Not Allowed, indicating that the server does not offer an SSE stream at this endpoint.
If the server initiates an SSE stream:
The server MAY send JSON-RPC requests and notifications on the stream.
These messages SHOULD be unrelated to any concurrently-running JSON-RPC request from the client.
The server MUST NOT send a JSON-RPC response on the stream unless resuming a stream associated with a previous client request.
The server MAY close the SSE stream at any time.
The client MAY close the SSE stream at any time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions