Expand description
The MCP Streamable HTTP client transport.
A conformant remote MCP server is reached by POSTing a JSON-RPC message to a
single endpoint; the server replies with either a application/json body (one
message) or a text/event-stream (SSE) carrying one or more messages. A
server-assigned Mcp-Session-Id (returned on initialize) is echoed on every
subsequent request. Server→client notifications ride an optional long-lived
GET SSE stream.
The transport is stream-agnostic (it reuses the hand-rolled net::http
client): https:// runs over TCP+TLS (optionally mutual TLS), http:// over
plain TCP (a local sidecar), unix: over a unix socket, and vsock: over
AF_VSOCK. None of these spawns a process: the transport has no local exec
surface, so a hostile server config cannot turn into command execution here.
Structs§
- Auth
Response - The AAuth-relevant fields of a server response. Handed to
RequestSigner::on_responseso the signer can satisfy a runtimeAAuth-Requirementand decide whether a retry would now succeed. - Http
Transport - The Streamable HTTP transport for one MCP server. Cheap to hold; each request
opens a fresh connection (
Connection: close), so there is no persistent socket to reap.sessionis set from the server’sMcp-Session-Idon the first response and echoed thereafter.
Enums§
- Http
Error - An MCP transport error (connect / HTTP / protocol).
- McpEndpoint
- A resolved MCP endpoint: where to connect + the HTTP
path/Hostto send.
Traits§
- Request
Signer - A per-request AAuth signer. The transport calls [
sign] just before each POST (the returned(name, value)pairs become request headers — the RFC 9421Signature-Input/Signature/Signature-Key), and [on_response] after, to react to the server’sAAuth-Requirement(adopt an access token, run the Person-Server flow) and re-sign+retry. Deliberately a trait, not an implementation: the crypto lives in the caller, so this crate stays free of any crypto dependency.
Functions§
- authority_
of - The
Hostauthority (host[:port]) of an MCP endpoint URL — the@authorityAAuth signs over.localhostfor non-TCP endpoints. Best-effort (a parse failure yields an empty string).
Type Aliases§
- Event
Stream - An owning SSE reader over the notification
GETstream (a boxed transport stream, so it survives on the notification thread).