|
Entropic 2.11.1
Local-first agentic inference engine
|
Manages a collection of ToolBase instances. More...
#include <entropic/mcp/tool_registry.h>
Public Member Functions | |
| void | register_tool (ToolBase *tool) |
| Register a tool instance. | |
| bool | has_tool (const std::string &name) const |
| Check if a tool is registered by name. | |
| std::string | get_tools_json () const |
| Get all registered tool definitions as a JSON array string. | |
| std::vector< const ToolDefinition * > | get_definitions () const |
| Get all registered tool definitions. | |
| ServerResponse | dispatch (const std::string &name, const std::string &args_json) |
| Dispatch a tool call to the registered tool's execute(). | |
| ToolBase * | get_tool (const std::string &name) const |
| Get a registered tool by name. | |
Manages a collection of ToolBase instances.
Replaces the dict-dispatch boilerplate repeated across servers. Servers call register_tool() during construction and the registry handles get_tools() and dispatch() automatically.
Definition at line 31 of file tool_registry.h.
| ServerResponse entropic::ToolRegistry::dispatch | ( | const std::string & | name, |
| const std::string & | args_json | ||
| ) |
Dispatch a tool call to the registered tool's execute().
Dispatch a tool call to the registered tool.
| name | Tool name. |
| args_json | JSON arguments string. |
An unregistered name is answered with an error ServerResponse — the missing tool is never dereferenced.
| name | Tool name (without server prefix). |
| args_json | JSON arguments string. |
result is "Error: Unknown tool '<name>'" and whose directives are empty. @req REQ-MCP-003 @req REQ-MCP-002 Definition at line 115 of file tool_registry.cpp.
| std::vector< const ToolDefinition * > entropic::ToolRegistry::get_definitions | ( | ) | const |
Get all registered tool definitions.
Definition at line 91 of file tool_registry.cpp.
| ToolBase * entropic::ToolRegistry::get_tool | ( | const std::string & | name | ) | const |
Get a registered tool by name.
| name | Tool name. |
| name | Tool name (without server prefix). |
Definition at line 137 of file tool_registry.cpp.
| std::string entropic::ToolRegistry::get_tools_json | ( | ) | const |
Get all registered tool definitions as a JSON array string.
Get all registered tool definitions as JSON array.
Emits inputSchema (camelCase), matching both the bundled data/tools/*/*.json descriptors and the plugin C ABI, so the schema lookup path is uniform across server kinds.
{name, description, inputSchema} object per registered tool; "[]" for an empty registry. @req REQ-MCP-003 @req REQ-MCP-008 Definition at line 70 of file tool_registry.cpp.
| bool entropic::ToolRegistry::has_tool | ( | const std::string & | name | ) | const |
Check if a tool is registered by name.
| name | Tool name. |
| name | Tool name (without server prefix). |
Definition at line 53 of file tool_registry.cpp.
| void entropic::ToolRegistry::register_tool | ( | ToolBase * | tool | ) |
Register a tool instance.
| tool | Non-owning pointer to a ToolBase. Caller retains ownership. |
Defensive by design: registration runs inside server constructors, where a failed load_tool_definition or a copy-paste name collision would otherwise surface as a crash at the model's first tool call. A nullptr is a logged no-op (never a stored null entry) and a duplicate name logs a warning before replacing the entry.
| tool | Non-owning pointer to a ToolBase; the server retains ownership. NULL is tolerated and logged. @req REQ-MCP-003 |
Definition at line 32 of file tool_registry.cpp.