Module runtime

Module runtime 

Source
Expand description

Runtime components for bidirectional transport

This module provides unified bidirectional communication support for all duplex transports (STDIO, TCP, Unix Socket, HTTP, WebSocket) with full MCP 2025-06-18 compliance.

§Architecture

Generic Abstraction: TransportDispatcher<T> works with any Transport

  • Sends server-initiated requests via transport
  • Correlates responses with pending requests
  • Implements ServerRequestDispatcher trait

Specialized Implementations:

  • StdioDispatcher: Optimized for stdin/stdout (line-delimited JSON)
  • TransportDispatcher<TcpTransport>: For TCP sockets
  • TransportDispatcher<UnixTransport>: For Unix domain sockets
  • http::HttpDispatcher: For HTTP + SSE sessions (feature-gated)
  • websocket::WebSocketDispatcher: For WebSocket connections (feature-gated)

All share the same request correlation and error handling logic.

Structs§

StdioDispatcher
STDIO dispatcher for server-initiated requests
TransportDispatcher
Generic dispatcher for any Transport implementation

Enums§

StdioMessage
Internal message type for STDIO transport

Functions§

run_stdio_bidirectional
Run MCP server over STDIO transport with full bidirectional support
run_transport_bidirectional
Run MCP server with any Transport implementation with full bidirectional support