ExMCP.ACP.Registry (ex_mcp v0.9.2)

View Source

Helpers for the public ACP agent registry.

The registry is distributed as JSON and lists ACP-compatible agents plus their distribution metadata. These helpers keep ExMCP clients from having to hard-code the CDN URL or common lookup details.

Summary

Functions

Returns all agent entries in a decoded registry map.

Returns the public ACP registry URL.

Returns a distribution entry such as "npx" or "binary".

Fetches and decodes the ACP registry.

Searches agent id, name, and description fields case-insensitively.

Finds an agent by exact id or name, falling back to case-insensitive lookup.

Builds an npx command from an agent registry entry.

Decodes registry JSON.

Types

agent()

@type agent() :: map()

registry()

@type registry() :: map()

Functions

agents(arg1)

@spec agents(registry()) :: [agent()]

Returns all agent entries in a decoded registry map.

default_url()

@spec default_url() :: String.t()

Returns the public ACP registry URL.

distribution(agent, kind)

@spec distribution(agent(), String.t() | atom()) :: map() | nil

Returns a distribution entry such as "npx" or "binary".

fetch(opts \\ [])

@spec fetch(keyword()) :: {:ok, registry()} | {:error, any()}

Fetches and decodes the ACP registry.

Options:

  • :url - registry URL, defaults to the public latest registry.
  • :timeout - request timeout in milliseconds, defaults to 15 seconds.
  • :headers - additional HTTP request headers.
  • :http_client - test hook taking (url, headers, timeout) and returning {:ok, body} or {:error, reason}.

find_agents(registry, query)

@spec find_agents(registry(), String.t()) :: [agent()]

Searches agent id, name, and description fields case-insensitively.

get_agent(registry, id_or_name)

@spec get_agent(registry(), String.t()) :: agent() | nil

Finds an agent by exact id or name, falling back to case-insensitive lookup.

npx_command(agent)

@spec npx_command(agent()) ::
  {:ok, [String.t()]} | {:error, :npx_distribution_not_found}

Builds an npx command from an agent registry entry.

Returns {:error, :npx_distribution_not_found} when the agent does not have an npx distribution.

parse(json)

@spec parse(iodata()) :: {:ok, registry()} | {:error, Jason.DecodeError.t()}

Decodes registry JSON.