ExMCP.Registry (ex_mcp v0.10.0)

View Source

Registry for managing tools, resources, and prompts in ExMCP.

The Registry provides a centralized way to register and lookup MCP capabilities. It supports dynamic registration and efficient lookup operations.

Summary

Functions

Returns a specification to start this module under a supervisor.

Lists all capabilities of a given type.

Lists all capabilities.

Looks up a capability by type and name.

Starts the registry.

Types

capability()

@type capability() :: %{
  name: String.t(),
  type: capability_type(),
  module: module(),
  metadata: map()
}

capability_type()

@type capability_type() :: :tool | :resource | :prompt

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

list(registry \\ __MODULE__, type)

@spec list(GenServer.server(), capability_type()) :: [capability()]

Lists all capabilities of a given type.

list_all(registry \\ __MODULE__)

@spec list_all(GenServer.server()) :: [capability()]

Lists all capabilities.

lookup(registry \\ __MODULE__, type, name)

@spec lookup(GenServer.server(), capability_type(), String.t()) ::
  {:ok, capability()} | {:error, :not_found}

Looks up a capability by type and name.

register(registry \\ __MODULE__, type, name, module, metadata \\ %{})

@spec register(GenServer.server(), capability_type(), String.t(), module(), map()) ::
  :ok

Registers a capability.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Starts the registry.

unregister(registry \\ __MODULE__, type, name)

@spec unregister(GenServer.server(), capability_type(), String.t()) :: :ok

Unregisters a capability.