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

Discovers selected MCP tools under a run's current authorization.

Register application-owned connection modules in trusted configuration.

    config :nous, :mcp,
      docs: MyApp.DocsConnection,
      helpdesk: [connection: MyApp.HelpdeskConnection, requires_approval: ["update_ticket"]]

`:requires_approval` accepts a boolean or a list of remote name strings.
The default is `false`. MCP annotations cannot change this setting. Normal
Nous permission rules also apply to the qualified name, e.g.
`helpdesk__update_ticket`.

The run discovers a fresh catalog and reauthorizes each call. Errors carry
`{:mcp, connection_alias, reason}`. A missing registration, an empty
catalog, and a missing selected name have distinct reasons. See
`Nous.MCP.Adapter` for remote failure and transport error semantics.

Selected tools must supply an object input schema. Nous validates arguments
after approval edits, including nested required fields, additional properties,
array items, type unions, numeric and size bounds, enum, const, boolean
subschemas, and allOf/anyOf/oneOf/not. An unsupported assertion, such as
`$ref`, `pattern` or `format`, fails discovery with
`{:invalid_descriptor, remote_name}`. Invalid arguments fail locally with
`:invalid_arguments`.

# `error`

```elixir
@type error() :: {:mcp, String.t(), atom() | {atom(), String.t()}}
```

# `selections`

```elixir
@type selections() :: %{optional(String.t()) =&gt; [String.t()]}
```

# `tools`

```elixir
@spec tools(selections(), Nous.RunContext.t()) ::
  {:ok, [Nous.Tool.t()]} | {:error, error()}
```

Build selected tools for this run using its authorized connections.

For direct use, set `mcp_grants:` when constructing the `RunContext`.
Requested selections must be a subset of those grants. Each tool checks
the invocation context's grants again before resolving its client.

---

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