# `ExMCP.Authorization.Interceptor`
[🔗](https://github.com/azmaveth/ex_mcp/blob/v1.0.0/lib/ex_mcp/authorization/interceptor.ex#L1)

Request interceptor that automatically adds authorization headers.

This module provides middleware functionality to ensure all MCP requests
include proper authorization headers when tokens are available.

# `add_auth_headers`

```elixir
@spec add_auth_headers(
  map() | keyword(),
  keyword()
) :: {:ok, map() | keyword()} | {:error, any()}
```

Adds authorization headers to a request if a token is available.

Options:
- `:token_manager` - PID or name of TokenManager process
- `:token` - Static token to use (alternative to token_manager)
- `:auth_type` - Authorization type (default: "Bearer")

# `handle_response`

```elixir
@spec handle_response({:ok, any()} | {:error, any()}, map()) ::
  {:ok, any()} | {:retry, map()} | {:error, any()}
```

Processes a response and handles authorization errors.

Returns:
- `{:ok, response}` - Response is fine, continue processing
- `{:retry, auth_params}` - Need to retry with authentication
- `{:error, reason}` - Unrecoverable error

# `wrap_request_fn`

```elixir
@spec wrap_request_fn(
  (map() -&gt; {:ok, any()} | {:error, any()}),
  keyword()
) :: (map() -&gt; {:ok, any()} | {:error, any()})
```

Creates an authorization-aware request function.

This wraps a request function to automatically add auth headers and
handle authorization errors with retry logic.

---

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