McpClient
A Model Context Protocol client over the Streamable HTTP transport.
It speaks the current revision (MODERN_VERSION, stateless: every request carries its protocol version, client info and capabilities in _meta, and the MCP-Protocol-Version, Mcp-Method, Mcp-Name and Mcp-Param-* headers mirror them) and falls back to the legacy, session-based revisions (initialize handshake, Mcp-Session-Id) when the server turns out to be one — the "dual-era" client of the spec. The era is detected on the first request and cached. The deprecated HTTP+SSE transport is not supported.
Each request is its own POST; the reply is a JSON object or an SSE stream carrying notifications/progress before the response. Cancelling the calling coroutine closes the stream, which is the cancellation signal.
It declares elicitation (form and URL modes): a server that needs the user's input mid-call — InputRequiredResult on 2026-07-28 (SEP-2322: the client asks, then retries with inputResponses and the echoed requestState), elicitation/create on a legacy session stream — is answered through callTool's onInput; without one the answer is cancel. Sampling and roots are not declared. capabilities can add extensions, e.g. McpApps.CLIENT_CAPABILITIES for MCP Apps.
Parameters
sent with every request, e.g. a static API key header.
supplies (and refreshes) bearer tokens; see McpAuth.
Constructors
Properties
Functions
Call tool with arguments. onProgress receives the server's progress notifications while it runs.
Call a tool by name (no x-mcp-header mirroring; prefer the McpTool overload).
The contents of the resource at uri (text and/or base64 blobs).