OptionalauthAn OAuth client provider to use for authentication.
token() is called before every request to obtain the
bearer token. When the server responds with 401, onUnauthorized()
is called (if provided) to refresh credentials, then the request is retried once. If
the retry also gets 401, or onUnauthorized is not provided, UnauthorizedError
is thrown.
For simple bearer tokens: { token: async () => myApiKey }.
For OAuth flows, pass an OAuthClientProvider implementation
directly — the transport adapts it to AuthProvider internally. Interactive flows: after
UnauthorizedError, redirect the user, then call
finishAuth with the authorization code before
reconnecting.
OptionalfetchCustom fetch implementation used for all network requests.
OptionalprotocolThe MCP protocol version to include in the mcp-protocol-version header on all requests.
When reconnecting with a preserved sessionId, set this to the version negotiated during the original
handshake so the reconnected transport continues sending the required header.
OptionalreconnectionOptions to configure the reconnection behavior.
OptionalreconnectionCustom scheduler for reconnection attempts. If not provided, setTimeout is used.
See ReconnectionScheduler.
OptionalrequestCustomizes HTTP requests to the server.
OptionalsessionSession ID for the connection. This is used to identify the session on the server. When not provided and connecting to a server that supports session IDs, the server will generate a new session ID.
Configuration options for the
StreamableHTTPClientTransport.