ExMCP.Server.Tools.Registry (ex_mcp v0.10.0)
View SourceRuntime tool registry that manages tool definitions and handlers.
This module provides a simpler alternative to compile-time metaprogramming by using runtime registration of tools.
Summary
Functions
Calls a tool by name.
Returns a specification to start this module under a supervisor.
Gets a tool's definition and handler.
Lists all registered tools.
Registers a tool with its handler.
Registers multiple tools at once.
Starts the tool registry.
Types
Functions
@spec call_tool(GenServer.server(), String.t(), map(), any()) :: {:ok, any()} | {:ok, any(), any()} | {:error, any()}
Calls a tool by name.
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec get_tool(GenServer.server(), String.t()) :: {:ok, {tool_definition(), handler()}} | {:error, :not_found}
Gets a tool's definition and handler.
@spec list_tools(GenServer.server()) :: [tool_definition()]
Lists all registered tools.
@spec register_tool(GenServer.server(), tool_definition(), handler()) :: :ok
Registers a tool with its handler.
@spec register_tools(GenServer.server(), [{tool_definition(), handler()}]) :: :ok
Registers multiple tools at once.
@spec start_link(keyword()) :: GenServer.on_start()
Starts the tool registry.