Nous.MCP (nous v0.21.1)

Copy Markdown View Source

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.

Summary

Functions

Build selected tools for this run using its authorized connections.

Types

error()

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

selections()

@type selections() :: %{optional(String.t()) => [String.t()]}

Functions

tools(selections, ctx)

@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.