StreamableHttpClientTransport

constructor(client: HttpClient, url: String, reconnectionOptions: ReconnectionOptions = ReconnectionOptions(), maxInlineSseEventSize: Int = DEFAULT_MAX_INLINE_SSE_EVENT_SIZE, requestBuilder: HttpRequestBuilder.() -> Unit = {})(source)

Parameters

client

Ktor HTTP client used for all requests

url

MCP endpoint URL

reconnectionOptions

reconnection backoff and retry-limit settings for the SSE stream

maxInlineSseEventSize

maximum size, in characters, of a single inline SSE event parsed from a POST response; a server that exceeds it (including by never terminating an event) fails the send with io.modelcontextprotocol.kotlin.sdk.shared.TooLongFrameException. Defaults to 16 MiB.

requestBuilder

builder applied to every outgoing HTTP request, e.g. for adding auth headers


constructor(client: HttpClient, url: String, reconnectionTime: Duration?, requestBuilder: HttpRequestBuilder.() -> Unit = {})(source)

Deprecated

Use constructor with ReconnectionOptions

Replace with

import kotlin.time.Duration.Companion.seconds
import io.modelcontextprotocol.kotlin.sdk.client.ReconnectionOptions
StreamableHttpClientTransport(client, url, ReconnectionOptions(initialReconnectionDelay = reconnectionTime ?: 1.seconds), requestBuilder)