Codex.MCP.Client (Codex SDK v0.3.0)

View Source

Minimal MCP client responsible for performing the handshake with external servers and providing lightweight tool discovery/invocation helpers with caching and retries.

Summary

Functions

Calls a tool with optional retry/backoff and approval callbacks.

Returns capabilities advertised by the MCP server.

Performs a handshake against the given transport.

Lists available tools, applying allow/block filters and caching results unless cache?: false is supplied.

Types

capabilities()

@type capabilities() :: %{optional(String.t()) => term()}

t()

@type t() :: %Codex.MCP.Client{
  capabilities: capabilities(),
  tool_cache: map(),
  transport: transport_ref()
}

transport_ref()

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

Functions

call_tool(client, tool, args, opts \\ [])

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

Calls a tool with optional retry/backoff and approval callbacks.

capabilities(client)

@spec capabilities(t()) :: capabilities()

Returns capabilities advertised by the MCP server.

handshake(transport, opts \\ [])

@spec handshake(
  transport_ref(),
  keyword()
) :: {:ok, t()} | {:error, term()}

Performs a handshake against the given transport.

list_tools(client, opts \\ [])

@spec list_tools(
  t(),
  keyword()
) :: {:ok, [map()], t()} | {:error, term()}

Lists available tools, applying allow/block filters and caching results unless cache?: false is supplied.