Available on crate feature
mcp only.Expand description
Streamable-HTTP (and SSE) MCP transport.
Implements the MCP “Streamable HTTP” transport introduced in revision
2025-03-26 and carried forward in later revisions. A single HTTP endpoint
serves every JSON-RPC message:
- The client
POSTs a JSON-RPC request (or notification) to the endpoint. - The server replies with either a single
application/jsonbody (one JSON-RPC message) or atext/event-streambody (Server-Sent Events, eachdata:line carrying one JSON-RPC message). Either way, this transport resolves theJsonRpcResponsewhoseidmatches the request it sent. - The server may issue a
Mcp-Session-Idheader on theinitializeresponse; the client echoes it on all subsequent requests. - After initialization the client sends the negotiated
MCP-Protocol-Versionheader on every request, as the spec mandates.
Authentication is supplied as a bearer token / OAuth access token (sent as an
Authorization: Bearer … header) or arbitrary custom headers.
The transport is generic over the HTTP layer via HttpPoster: production
code uses ReqwestPoster (the default), while tests inject a scripted
poster to exercise the JSON and SSE response paths deterministically with no
live network.
Structs§
- Http
Reply - A single HTTP response from an MCP endpoint, normalised across the two streamable-HTTP body shapes.
- Http
Request - The HTTP request a transport wants to make, in transport-neutral form.
- Reqwest
Poster - Default
HttpPosterbacked byreqwest. - Streamable
Http Transport - Streamable-HTTP MCP transport.
Enums§
- McpAuth
- Authentication strategy for an HTTP MCP connection.
Traits§
- Http
Poster - Abstraction over the act of
POSTing one JSON-RPC message to the MCP endpoint.