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

Copy Markdown View Source

Client-library boundary for MCP discovery and invocation.

Return wire-format descriptors with string keys, including "name" and an object "inputSchema". A page ends with a cursor string or nil.

Successful calls return model-visible JSON data. Keep credentials, HTTP headers and host-only metadata outside this value. Use :remote_error for a reported tool failure, :unavailable when the call could not start, and :unknown_outcome if a dispatched call lost its response or timed out. Adapters must never replay a call whose outcome is unknown.

Summary

Types

descriptor()

@type descriptor() :: %{required(String.t()) => term()}

error()

@type error() :: Nous.MCP.Connection.error() | :remote_error | :unknown_outcome

Callbacks

call_tool(term, t, map)

@callback call_tool(term(), String.t(), map()) :: {:ok, term()} | {:error, error()}

list_tools(term, arg2)

@callback list_tools(term(), String.t() | nil) ::
  {:ok, [descriptor()], String.t() | nil} | {:error, error()}