Skip to main content

Module transport

Module transport 

Source
Expand description

One command line for the three MCP transports.

Every server in the suite is started the same way:

<server>                                   # stdio, for a client that spawns it
<server> --transport streamable-http       # HTTP on 127.0.0.1:8000, path /mcp
<server> --transport sse --port 8001       # the older HTTP+SSE transport

Over streamable HTTP the SDK speaks both current protocol revisions on one endpoint: 2026-07-28 (stateless, server/discover, per-request _meta) and 2025-11-25 (initialize handshake, Mcp-Session-Id). Responses stream as server-sent events; a GET on the same path opens the server-to-client event stream. --transport sse serves the 2024-11-05 HTTP+SSE transport for clients that still expect it: GET /sse opens the event stream, whose first event names the /messages/?sessionId=... endpoint the client posts to.

The listener binds the loopback interface unless told otherwise. There is no authentication here: put the server behind a gateway you trust before binding a routable address.

This module (transport.rs and transport/) depends only on the SDK and on a [ServerHandler] passed in, so it is copied verbatim into every Rust server of the suite. Nothing in it knows what the tools are.

Structs§

Options
What the command line asked for.

Enums§

Command
The outcome of reading the command line.
Transport
How the server talks to its client.

Constants§

DEFAULT_HOST
Where the listeners bind unless told otherwise.
DEFAULT_PORT
The port the HTTP transports listen on unless told otherwise.
MESSAGE_PATH
Where the legacy transport’s client messages are posted.
SSE_PATH
Where the legacy transport’s event stream is opened.
STREAMABLE_HTTP_PATH
The streamable HTTP endpoint.

Functions§

parse
Read the command line.
run
Serve factory’s handler as name according to the command line.
serve
Serve the handler over the chosen transport until the client goes away (stdio) or the process is interrupted (HTTP).
usage
The usage text, for --help and for a usage error.