# `Nous.MCP.Connection`
[🔗](https://github.com/nyo16/nous/blob/v0.21.1/lib/nous/mcp/connection.ex#L1)

Resolves an authorized MCP client for the current run.

Implement `connect/1` in the host application. Read the authenticated
identity from `ctx.principal` for a user-scoped client, or return an
application-owned service client. The host supervises clients and manages
credentials, consent and refresh. Nous calls this callback during discovery
and again immediately before every invocation.

# `client`

```elixir
@type client() :: {module(), term()}
```

# `error`

```elixir
@type error() ::
  :unauthenticated | :authorization_required | :forbidden | :unavailable
```

# `connect`

```elixir
@callback connect(Nous.RunContext.t()) :: {:ok, client()} | {:error, error()}
```

---

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