# `ExMCP.TransportManager`
[🔗](https://github.com/azmaveth/ex_mcp/blob/v1.0.0/lib/ex_mcp/transport_manager.ex#L1)

Transport 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"]}
      ],
      fallback_strategy: :sequential,
      health_check_timeout: 5_000
    ]

    {:ok, {transport_mod, transport_state}} = TransportManager.connect(opts)

# `connect_result`

```elixir
@type connect_result() :: {:ok, {module(), any()}} | {:error, any()}
```

# `fallback_strategy`

```elixir
@type fallback_strategy() :: :sequential | :parallel | :fastest
```

# `transport_spec`

```elixir
@type transport_spec() :: {module(), keyword()}
```

# `connect`

```elixir
@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)

# `default_config`

```elixir
@spec default_config(atom()) :: keyword()
```

Gets the default transport configuration for common scenarios.

# `health_check`

```elixir
@spec health_check(module(), keyword(), timeout()) :: :ok | {:error, any()}
```

Checks if a transport module is available and healthy.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
