Skip to main content

Module http

Module http 

Source
Expand description

MCP Streamable HTTP transport (the 2025-03-26 transport that superseded the older HTTP+SSE pair).

  • POST /mcp — the client sends one JSON-RPC message (or a batch array). The reply is delivered as application/json by default, or as a one-shot text/event-stream (SSE) event when the client Accepts it. A body of only notifications gets 202 Accepted with no content.
  • GET /mcp — opens a standalone server→client SSE stream. This server has no server-initiated messages, so the stream simply stays open with keep-alives; it exists for spec compliance.

/ is also wired to the same handlers for convenience. The JSON-RPC semantics are identical to the stdio and TCP transports — only framing differs (see crate::server::dispatch_http_body).

Functions§

router
Build the axum router for the HTTP transport. Exposed so tests can drive it with tower::ServiceExt::oneshot without binding a socket.
run
Bind addr and serve the HTTP transport until the process is killed.