ExMCP.TransportManager (ex_mcp v0.10.0)
View SourceTransport abstraction layer with fallback mechanisms.
Provides a unified interface for transport selection and automatic fallback when primary transports fail. Supports configuration-based transport priority and health checking.
Features
- Smart transport selection: Automatically choose best available transport
- Fallback mechanisms: Try multiple transports in priority order
- Health checking: Verify transport availability before use
- Configuration-driven: Define transport priorities via config
- Error recovery: Handle transport failures gracefully
Example
opts = [
transports: [
{ExMCP.Transport.HTTP, [url: "http://localhost:8080"]},
{ExMCP.Transport.Stdio, [command: "my-server"]},
{ExMCP.Transport.SSE, [url: "http://localhost:8080/events"]}
],
fallback_strategy: :sequential,
health_check_timeout: 5_000
]
{:ok, {transport_mod, transport_state}} = TransportManager.connect(opts)
Summary
Functions
Connects using the best available transport from the provided list.
Gets the default transport configuration for common scenarios.
Checks if a transport module is available and healthy.
Types
Functions
@spec connect(keyword()) :: connect_result()
Connects using the best available transport from the provided list.
Options
:transports- List of{transport_module, opts}tuples in priority order:fallback_strategy- How to handle fallbacks (:sequential,:parallel,:fastest):health_check_timeout- Timeout for transport health checks (default: 5000ms):max_retries- Maximum retries per transport (default: 2):retry_interval- Interval between retries (default: 1000ms)
Gets the default transport configuration for common scenarios.
Checks if a transport module is available and healthy.