Skip to main content

Module http

Module http 

Source
Expand description

The MCP Streamable HTTP client transport (v2.0.0). RFC 0004 §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 which spawns a process (RFC 0012: no local exec surface).

Structs§

AuthResponse
The AAuth-relevant fields of a server response (RFC 0023 §5 — the request loop). Handed to RequestSigner::on_response so the signer can satisfy a runtime AAuth-Requirement and decide whether a retry would now succeed.
HttpTransport
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. session is set from the server’s Mcp-Session-Id on the first response and echoed thereafter.

Enums§

HttpError
An MCP transport error (connect / HTTP / protocol).
McpEndpoint
A resolved MCP endpoint: where to connect + the HTTP path/Host to send.

Traits§

RequestSigner
A per-request signer (RFC 0023 — AAuth). The transport calls [sign] just before each POST (the returned (name, value) pairs become request headers — the RFC 9421 Signature-Input/Signature/Signature-Key), and [on_response] after, to react to the server’s AAuth-Requirement (adopt an access token, run the Person-Server flow) and re-sign+retry. Kept dependency-free here — the CRYPTO lives in the caller (agentd’s aauth module); this crate only owns the seam, so agentd-mcp gains no crypto dep.

Functions§

authority_of
The Host authority (host[:port]) of an MCP endpoint URL — the @authority AAuth signs over. localhost for non-TCP endpoints. Best-effort (a parse failure yields an empty string).

Type Aliases§

EventStream
An owning SSE reader over the notification GET stream (a boxed transport stream, so it survives on the notification thread).