Expand description
§TurboMCP WebSocket Transport
WebSocket bidirectional transport implementation for the TurboMCP SDK. This crate provides MCP 2025-11-25 bidirectional communication, server-initiated requests, and elicitation handling.
§Features
- Bidirectional Communication: Full request-response patterns with correlation
- Elicitation Support: Server-initiated requests with timeout handling
- Automatic Reconnection: Configurable exponential backoff retry logic
- Keep-Alive: Periodic ping/pong to maintain connections
- Compression: Optional message compression support
- TLS Support: Secure WebSocket connections (WSS)
- Metrics Collection: Comprehensive transport metrics and monitoring
- Background Tasks: Efficient management of concurrent operations
§Quick Start
ⓘ
use turbomcp_websocket::{WebSocketBidirectionalTransport, WebSocketBidirectionalConfig};
use turbomcp_transport_traits::Transport;
// Create client configuration
let config = WebSocketBidirectionalConfig::client("ws://localhost:8080".to_string())
.with_max_concurrent_elicitations(5)
.with_compression(true);
// Create and connect transport
let transport = WebSocketBidirectionalTransport::new(config).await?;
transport.connect().await?;
// Use the transport...§Architecture
The WebSocket transport is organized into focused components:
turbomcp-websocket/
├── config.rs # Configuration types and builders
├── types.rs # Core types and type aliases
├── connection.rs # Connection management and lifecycle
├── tasks.rs # Background task management
├── elicitation.rs # Elicitation handling and timeout management
├── mcp_methods.rs # MCP protocol method implementations
├── transport.rs # Main Transport trait implementation
└── bidirectional.rs # BidirectionalTransport trait implementationRe-exports§
pub use bidirectional::CorrelationInfo;pub use config::ReconnectConfig;pub use config::TlsConfig;pub use config::WebSocketBidirectionalConfig;pub use elicitation::ElicitationInfo;pub use transport::TransportStatus;pub use types::MessageProcessingResult;pub use types::PendingElicitation;pub use types::WebSocketBidirectionalTransport;pub use types::WebSocketConnectionStats;pub use types::WebSocketStreamHandler;
Modules§
- bidirectional
- Bidirectional transport implementation for WebSocket
- config
- Configuration types for WebSocket bidirectional transport
- connection
- Connection management for WebSocket bidirectional transport
- elicitation
- Elicitation handling for WebSocket bidirectional transport
- mcp_
methods - MCP bidirectional methods for WebSocket transport
- tasks
- Background task management for WebSocket bidirectional transport
- transport
- Main transport implementation for WebSocket bidirectional transport
- types
- Core types and type aliases for WebSocket bidirectional transport
Structs§
- Connection
State - Connection state for bidirectional communication
- Correlation
Context - Correlation context for request-response patterns
- Transport
Capabilities - Describes the capabilities of a transport implementation.
- Transport
Config - Configuration for a transport instance.
- Transport
Event Emitter - An emitter for broadcasting
TransportEvents to listeners. - Transport
Message - A wrapper for a message being sent or received over a transport.
- Transport
Message Metadata - Metadata associated with a
TransportMessage. - Transport
Metrics - A serializable snapshot of a transport’s performance metrics.
Enums§
- Message
Direction - Message direction in the transport layer
- Transport
Error - Represents errors that can occur during transport operations.
- Transport
Event - Represents events that occur within a transport’s lifecycle.
- Transport
State - Represents the current state of a transport connection.
- Transport
Type - Enumerates the types of transports supported by the system.
Traits§
- Bidirectional
Transport - A trait for transports that support full-duplex, bidirectional communication.
- Transport
- The core trait for all transport implementations.
Type Aliases§
- Transport
Result - A specialized
Resulttype for transport operations.