Nous.MCP.Connection behaviour (nous v0.21.1)

Copy Markdown View Source

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.

Summary

Types

client()

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

error()

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

Callbacks

connect(t)

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