Skip to main content

Module transport

Module transport 

Source
Expand description

Transport layer implementations

This module provides concrete implementations of the transport traits for different communication protocols including STDIO, HTTP, and WebSocket.

§When to Use Transport Directly

Most users should use the high-level server/client APIs (McpServer, McpClient) which handle transport details automatically. Use Transport directly only when:

  • Custom Transport: Implementing new transport mechanisms
  • Transport Middleware: Adding logging, metrics, or transformations
  • Fine-Grained Control: Managing connection lifecycle manually
  • Protocol Bridging: Connecting different transport types

§Available Transports

§STDIO Transport (Default)

use prism_mcp_rs::transport::StdioServerTransport;
use prism_mcp_rs::server::McpServer;

let transport = StdioServerTransport::new();
let server = McpServer::new("server".to_string(), "1.0.0".to_string());
// server.run_with_transport(transport).await?;

§HTTP Transport

// Requires "http" feature in Cargo.toml:
// prism-mcp-rs = { version = "3", features = ["http"] }
use prism_mcp_rs::transport::HttpServerTransport;

// HttpServerTransport takes a bind address directly
let transport = HttpServerTransport::new("127.0.0.1:8080");

§WebSocket Transport

// Requires "websocket" feature in Cargo.toml:
// prism-mcp-rs = { version = "3", features = ["websocket"] }
use prism_mcp_rs::transport::WebSocketServerTransport;

// WebSocketServerTransport uses new() method, not bind()
let transport = WebSocketServerTransport::new("127.0.0.1:9000");

§Transport Traits

The transport layer is built on several traits:

§Advanced Features

  • Authentication: HTTP transport supports various auth mechanisms
  • Compression: Streaming HTTP supports gzip/brotli/zstd (requires “compression” feature)
  • Prism Chunked Endpoints: Proprietary legacy-only helpers (requires “chunked-encoding” feature)
  • MCP 2026 Subscriptions: Request-scoped SSE is built into the standard HTTP transport
  • Legacy Server-Sent Events: Compatibility events route (requires “sse” feature)
  • Reconnection: Automatic reconnection with backoff
  • Metrics: Performance monitoring and statistics
  • HTTP/2: Multiplexed streaming support (requires “http2” feature)

§Implementation Note

The Transport trait is primarily an internal abstraction. Unless you’re implementing custom transports or need very specific control, use the high-level APIs provided by McpServer and McpClient.

Re-exports§

pub use endpoint_pool::is_request_idempotent;
pub use endpoint_pool::EndpointPoolConfig;
pub use endpoint_pool::EndpointPoolTransport;
pub use traits::ClientSubscription;
pub use traits::ConnectionState;
pub use traits::EventEmittingTransport;
pub use traits::FilterableTransport;
pub use traits::ReconnectConfig;
pub use traits::ReconnectableTransport;
pub use traits::ServerTransport;
pub use traits::Transport;
pub use traits::TransportConfig;
pub use traits::TransportEvent;
pub use traits::TransportStats;
pub use stdio::StdioClientTransport;
pub use stdio::StdioServerTransport;
pub use http::HttpClientTransport;
pub use http::HttpServerTransport;
pub use http::MtlsClientConfig;
pub use http::MtlsServerConfig;
pub use http_auth::AuthorizedHttpTransport;
pub use http_auth::AuthorizedHttpTransportBuilder;
pub use http_convenience::ConnectionStats;
pub use http_convenience::ErrorMetrics;
pub use http_convenience::HttpClientTransportBuilder;
pub use http_convenience::HttpEndpoints;
pub use http_convenience::PerformanceMetrics;
pub use http_convenience::RetryConfig;
pub use http_convenience::RetryPolicy;
pub use http_convenience::ServerInfo;
pub use http_convenience::TransportMetrics;
pub use websocket::WebSocketClientTransport;
pub use websocket::WebSocketServerTransport;
pub use streaming_http::ContentAnalyzer;
pub use streaming_http::ContentType;
pub use streaming_http::StreamingAnalysis;
pub use streaming_http::StreamingConfig;
pub use streaming_http::StreamingHttpClientTransport;
pub use streaming_http::StreamingStrategy;
pub use streaming_http::CompressionType;
pub use streaming_http::Http2Config;
pub use streaming_http::Http2StreamManager;
pub use streaming_http::PushPromise;
pub use streaming_http::StreamInfo;
pub use streaming_http::StreamState;

Modules§

endpoint_pool
Multi-endpoint transport with conservative, idempotency-aware failover.
http
HTTP transport implementation for MCP
http_auth
HTTP Transport with OAuth 2.1 Authorization Support
http_convenience
Production-grade convenience methods for HttpClientTransport
stdio
STDIO transport implementation for MCP
streaming_http
Proprietary Prism HTTP transport extensions
traits
Transport layer traits and abstractions
websocket
WebSocket transport implementation for MCP