barrel_mcp_client_http (barrel_mcp v2.0.2)
View SourceStreamable HTTP transport for barrel_mcp_client.
Implements MCP's Streamable HTTP transport (2025-03-26 onward) on the client side:
- POST every request with
Accept: application/json, text/event-stream. The server may answer with a single JSON envelope or with an SSE stream that interleaves server-initiated requests/notifications until the matching response arrives. - GET opens a long-lived SSE channel for unsolicited server-to-client traffic. Optional: a server may return 405, in which case server messages only arrive on POST streams.
- DELETE on close, with the captured
Mcp-Session-Id. MCP-Protocol-Versionheader echoed on every request after the initialize response has been processed by the client.- 401 with
WWW-Authenticatetriggers the configured auth refresh; the original request is retried once.
Each parsed SSE event's data: payload is forwarded to the owning client as {mcp_in, self(), Json}. The owner sees the same shape as it does from the stdio transport.
Summary
Functions
Open the long-lived GET SSE for unsolicited server messages. Idempotent: a second call while the stream is open is a no-op.
Set the negotiated protocol version. Once set, every outgoing request includes the MCP-Protocol-Version header.
Capture the Mcp-Session-Id returned on the initialize POST so subsequent requests can echo it.
Functions
Open the long-lived GET SSE for unsolicited server messages. Idempotent: a second call while the stream is open is a no-op.
Set the negotiated protocol version. Once set, every outgoing request includes the MCP-Protocol-Version header.
Capture the Mcp-Session-Id returned on the initialize POST so subsequent requests can echo it.