Expand description
Transport layer for FastMCP.
This crate provides transport implementations for MCP communication:
- Stdio: Standard input/output (primary transport)
- SSE: Server-Sent Events (HTTP-based streaming)
- WebSocket: Bidirectional web sockets
§Transport Design
Transports are designed around asupersync’s principles:
- Cancel-correctness: All operations check cancellation via
Cx::checkpoint() - Two-phase sends: Use reserve/commit pattern to prevent message loss
- Budget awareness: Operations respect the request’s budget constraints
§Wire Format
MCP uses newline-delimited JSON (NDJSON) for message framing:
- Each message is a single line of JSON
- Messages are separated by
\n - UTF-8 encoding is required
§Role in the System
fastmcp-transport is the I/O boundary for FastMCP. It is deliberately
protocol-agnostic: transports move JsonRpcMessage values in and out while
the server/client layers handle semantics. This keeps transport
implementations small, testable, and reusable.
If you need to add a new transport (for example, QUIC or a custom IPC), this is the crate to extend.
Modules§
- event_
store - Event store for SSE resumability.
- http
- HTTP transport for FastMCP.
- memory
- In-memory transport for testing MCP servers without subprocess spawning.
- sse
- Server-Sent Events (SSE) transport for MCP.
- websocket
- WebSocket transport for MCP.
Structs§
- Async
Line Reader - Async line reader with cancellation support.
- Async
Stdin - Async wrapper for stdin.
- Async
Stdio Transport - Async stdio transport with integrated cancellation support.
- Async
Stdout - Async wrapper for stdout.
- Codec
- Codec for encoding/decoding JSON-RPC messages.
- Send
Permit - A permit for sending a message via two-phase commit.
- Stdio
Transport - Stdio transport implementation.
Enums§
- Codec
Error - Codec error types.
- Transport
Error - Transport error types.
Traits§
- Transport
- Transport trait for cancel-correct message passing.
- TwoPhase
Transport - Extension trait for two-phase send operations.