# `ExMCP.Reliability.CircuitBreaker`
[🔗](https://github.com/azmaveth/ex_mcp/blob/v1.0.0/lib/ex_mcp/reliability/circuit_breaker.ex#L1)

Circuit breaker GenServer wrapper.

Provides a GenServer-based interface to the circuit breaker pattern for
protecting MCP services from cascading failures.

# `options`

```elixir
@type options() :: [
  failure_threshold: non_neg_integer(),
  success_threshold: non_neg_integer(),
  timeout: non_neg_integer(),
  reset_timeout: non_neg_integer(),
  error_filter: (any() -&gt; boolean())
]
```

# `call`

```elixir
@spec call(GenServer.server(), (-&gt; any())) :: any()
```

Executes a function through the circuit breaker.

# `call`

```elixir
@spec call(GenServer.server(), (-&gt; any()), timeout()) :: any()
```

Executes a function through the circuit breaker with timeout.

The function runs in a process spawned by the *caller*, never inside the
circuit breaker itself: a raising/exiting function can neither crash the
breaker nor block other callers. The breaker only admits the call and
records its outcome. The effective execution timeout is the breaker's
configured `:timeout` bounded by `timeout` (this argument).

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `close`

```elixir
@spec close(GenServer.server()) :: :ok
```

Manually closes the circuit breaker.

# `get_state`

```elixir
@spec get_state(GenServer.server()) :: ExMCP.Reliability.CircuitBreaker.Core.state()
```

Gets the current state of the circuit breaker.

# `get_stats`

```elixir
@spec get_stats(GenServer.server()) :: map()
```

Gets circuit breaker statistics.

# `open`

```elixir
@spec open(GenServer.server()) :: :ok
```

Manually opens the circuit breaker.

# `reset`

```elixir
@spec reset(GenServer.server()) :: :ok
```

Resets the circuit breaker to initial state.

# `start_link`

```elixir
@spec start_link(options()) :: GenServer.on_start()
```

Starts a circuit breaker process.

# `trip`

```elixir
@spec trip(GenServer.server()) :: :ok
```

Manually trips (opens) the circuit breaker.
Alias for open/1 to match test expectations.

---

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