Entropic 2.11.1
Local-first agentic inference engine
Loading...
Searching...
No Matches
entropic::ToolRegistry Class Reference

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().
 
ToolBaseget_tool (const std::string &name) const
 Get a registered tool by name.
 

Detailed Description

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.

Version
1.8.5

Definition at line 31 of file tool_registry.h.

Member Function Documentation

◆ dispatch()

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.

Parameters
nameTool name.
args_jsonJSON arguments string.
Returns
ServerResponse from the tool, or error response if unknown.
Version
1.8.5

An unregistered name is answered with an error ServerResponse — the missing tool is never dereferenced.

Parameters
nameTool name (without server prefix).
args_jsonJSON arguments string.
Returns
The tool's own ServerResponse when the name resolves; otherwise a response whose result is "Error: Unknown tool '<name>'" and whose directives are empty. @req REQ-MCP-003 @req REQ-MCP-002
Version
2.0.0

Definition at line 115 of file tool_registry.cpp.

◆ get_definitions()

std::vector< const ToolDefinition * > entropic::ToolRegistry::get_definitions ( ) const

Get all registered tool definitions.

Returns
Vector of ToolDefinition references.
Version
1.8.5
Returns
Exactly one non-owning ToolDefinition pointer per registered tool; an empty vector for an empty registry. Pointers stay valid for as long as the owning server holds its tools. @req REQ-MCP-003
Version
1.8.5

Definition at line 91 of file tool_registry.cpp.

◆ get_tool()

ToolBase * entropic::ToolRegistry::get_tool ( const std::string &  name) const

Get a registered tool by name.

Parameters
nameTool name.
Returns
Tool pointer, or nullptr if not found.
Version
1.8.5
Parameters
nameTool name (without server prefix).
Returns
Non-owning tool pointer, or nullptr when the name is not registered — callers must null-check before use. @req REQ-MCP-003
Version
1.8.5

Definition at line 137 of file tool_registry.cpp.

◆ get_tools_json()

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.

Returns
JSON array of tool definitions. Caller-owned string.
Version
1.8.5

Emits inputSchema (camelCase), matching both the bundled data/tools/&#42;/&#42;.json descriptors and the plugin C ABI, so the schema lookup path is uniform across server kinds.

Returns
JSON array string with one {name, description, inputSchema} object per registered tool; "[]" for an empty registry. @req REQ-MCP-003 @req REQ-MCP-008
Version
1.8.5

Definition at line 70 of file tool_registry.cpp.

◆ has_tool()

bool entropic::ToolRegistry::has_tool ( const std::string &  name) const

Check if a tool is registered by name.

Parameters
nameTool name.
Returns
true if registered.
Version
1.8.5
Parameters
nameTool name (without server prefix).
Returns
true when a tool of that name is registered, false for any unknown name. @req REQ-MCP-003
Version
1.8.5

Definition at line 53 of file tool_registry.cpp.

◆ register_tool()

void entropic::ToolRegistry::register_tool ( ToolBase tool)

Register a tool instance.

Parameters
toolNon-owning pointer to a ToolBase. Caller retains ownership.
Version
1.8.5

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.

Parameters
toolNon-owning pointer to a ToolBase; the server retains ownership. NULL is tolerated and logged. @req REQ-MCP-003
Version
1.8.5

Definition at line 32 of file tool_registry.cpp.


The documentation for this class was generated from the following files: