MCP client connection and request handling. Supports the modern 2026-07-28 stateless protocol and legacy initialization-based protocol revisions over the same Streamable HTTP endpoint.

Values

HEADER-MISMATCH

HEADER-MISMATCH: Int -32020

LEGACY-PROTOCOL-VERSION

LEGACY-PROTOCOL-VERSION: Str "2025-11-25"

META-CLIENT-CAPABILITIES

META-CLIENT-CAPABILITIES: Str "io.modelcontextprotocol/clientCapabilities"

META-CLIENT-INFO

META-CLIENT-INFO: Str "io.modelcontextprotocol/clientInfo"

META-LOG-LEVEL

META-LOG-LEVEL: Str "io.modelcontextprotocol/logLevel"

META-PROTOCOL-VERSION

META-PROTOCOL-VERSION: Str "io.modelcontextprotocol/protocolVersion"

META-SERVER-INFO

META-SERVER-INFO: Str "io.modelcontextprotocol/serverInfo"

MISSING-CLIENT-CAPABILITY

MISSING-CLIENT-CAPABILITY: Int -32021

MODERN-PROTOCOL-VERSION

MODERN-PROTOCOL-VERSION: Str "2026-07-28"

UNSUPPORTED-PROTOCOL-VERSION

UNSUPPORTED-PROTOCOL-VERSION: Int -32022

Functions

connect

fn (url: Str, client-info: ::mcp::types/ClientInfo, capabilities: ::mcp::types/ClientCapabilities?): ::mcp::types/Session
fn (url: Str, client-info: ::mcp::types/ClientInfo, capabilities: ::mcp::types/ClientCapabilities?, options: ::mcp::types/ConnectionOptions?): ::mcp::types/Session

Connect to an MCP server.

The default auto mode probes the modern 2026-07-28 protocol with server/discover and falls back to the legacy initialize handshake only when the response is not a recognized modern response. Pass ConnectionOptions with mode: "modern" to pin modern behavior or mode: "legacy" to skip the probe. Caller headers are retained on every request.

connect-legacy

fn (url: Str, client-info: ::mcp::types/ClientInfo, capabilities: ::mcp::types/ClientCapabilities?, base-headers: Map): ::mcp::types/Session

contains-x-mcp-header

fn (value: Any): Bool

default-server-capabilities

fn (): ::mcp::types/ServerCapabilities

default-server-info

fn (): ::mcp::types/ServerInfo

encode-header-value

fn (value: Str): Str

Encode an MCP routing header value using the Base64 sentinel when plain ASCII is unsafe.

initialize

fn (url: Str, client-info: ::mcp::types/ClientInfo, capabilities: ::mcp::types/ClientCapabilities?): ::mcp::types/Session
fn (url: Str, client-info: ::mcp::types/ClientInfo, capabilities: ::mcp::types/ClientCapabilities?, headers: Map): ::mcp::types/Session

Connect using the legacy initialize/initialized handshake.

Use connect for automatic modern/legacy negotiation. The four-argument form accepts base HTTP headers such as Authorization.

modern-params

fn (params: Map?, client-info: ::mcp::types/ClientInfo, capabilities: ::mcp::types/ClientCapabilities?, version: Str, log-level: Str?): Map

modern-probe

fn (url: Str, client-info: ::mcp::types/ClientInfo, capabilities: ::mcp::types/ClientCapabilities?, base-headers: Map, log-level: Str?): Map

modern-session

fn (url: Str, client-info: ::mcp::types/ClientInfo, capabilities: ::mcp::types/ClientCapabilities?, base-headers: Map, log-level: Str?, discovery: Map): ::mcp::types/Session

mrtr-retry-params

fn (params: Map?, result: Map, responses: Map?): Map

Build MRTR retry params without leaking fields from an earlier round.

ping

fn (session: ::mcp::types/Session): Bool

Check server connectivity using discovery for modern MCP or ping for legacy MCP.

property-header-analysis

fn (schema: Any, path: Vec): Map

request-context

fn (session: ::mcp::types/Session, method: Str, params: Map?, tool: ::mcp::types/Tool?): Map

Build the era-specific params and HTTP headers for an MCP request.

request-name

fn (method: Str, params: Map): Str?

response-json-rpc-message

fn (response: ::hot::http/HttpResponse): Map?

Extract a JSON-RPC message from JSON or buffered SSE transport responses.

session-era

fn (session: ::mcp::types/Session): Str

session-request

fn (session: ::mcp::types/Session, method: Str, params: Map?): Map

Send a request over an active MCP connection and return its result.

session-request-stream

fn (session: ::mcp::types/Session, method: Str, params: Map?): ::hot::http/StreamingHttpResponse

Send a streaming request over an active MCP connection.

session-request-stream-with-tool

fn (session: ::mcp::types/Session, method: Str, params: Map?, tool: ::mcp::types/Tool?): ::hot::http/StreamingHttpResponse

Send a streaming MCP request with optional tool header metadata.

session-request-with-input

fn (session: ::mcp::types/Session, method: Str, params: Map?, handler: Fn, max-rounds: Int): Map

Fulfill modern Multi Round-Trip Requests.

handler receives each requested server-to-client request and returns its response. The original request is retried with a fresh JSON-RPC ID, inputResponses, and the opaque requestState.

session-request-with-tool

fn (session: ::mcp::types/Session, method: Str, params: Map?, tool: ::mcp::types/Tool?): Map

Send an MCP request, optionally using a Tool definition for x-mcp-header mirroring.

session-request-with-tool-input

fn (session: ::mcp::types/Session, method: Str, params: Map?, tool: ::mcp::types/Tool, handler: Fn, max-rounds: Int): Map

MRTR request helper that also mirrors a tool's x-mcp-header parameters.

tool-header-analysis

fn (tool: ::mcp::types/Tool): Map

Validate and collect statically reachable x-mcp-header annotations from a tool.

tool-parameter-headers

fn (tool: ::mcp::types/Tool, arguments: Map?): Map

Build Mcp-Param-* headers for a modern HTTP tool call.

valid-header-suffix

fn (value: Any): Bool

valid-tool-for-session

fn (session: ::mcp::types/Session, tool: ::mcp::types/Tool): Bool

Return whether a tool definition is valid for the session transport.