StreamableHttpClientTransport
class StreamableHttpClientTransport(client: HttpClient, url: String, reconnectionOptions: ReconnectionOptions = ReconnectionOptions(), requestBuilder: HttpRequestBuilder.() -> Unit = {}) : AbstractClientTransport(source)
Client transport implementing the MCP Streamable HTTP transport specification.
Sends messages via HTTP POST and receives messages via HTTP GET with Server-Sent Events. Supports automatic SSE reconnection with exponential backoff, stream resumption via the Last-Event-ID header, and explicit session termination.
Parameters
client
Ktor HTTP client used for all requests
url
MCP endpoint URL
reconnectionOptions
reconnection backoff and retry-limit settings for the SSE stream
requestBuilder
builder applied to every outgoing HTTP request, e.g. for adding auth headers
Constructors
Link copied to clipboard
constructor(client: HttpClient, url: String, reconnectionOptions: ReconnectionOptions = ReconnectionOptions(), requestBuilder: HttpRequestBuilder.() -> Unit = {})
constructor(client: HttpClient, url: String, reconnectionTime: Duration?, requestBuilder: HttpRequestBuilder.() -> Unit = {})
Properties
Functions
Link copied to clipboard
Link copied to clipboard
suspend fun send(message: JSONRPCMessage, resumptionToken: String?, onResumptionToken: (String) -> Unit? = null)
Sends one or more messages with optional resumption support. This is the main send method that matches the TypeScript implementation.
Link copied to clipboard
Terminates the current session by sending a DELETE request to the server.