Class: ActionMCP::ToolsRegistry
- Inherits:
-
RegistryBase
- Object
- RegistryBase
- ActionMCP::ToolsRegistry
- Defined in:
- lib/action_mcp/tools_registry.rb
Overview
Registry for managing tools.
Class Method Summary collapse
- .item_klass ⇒ Object
-
.tool_call(tool_name, arguments, _metadata = {}) ⇒ Hash
Calls a tool with the given name and arguments.
Methods inherited from RegistryBase
clear!, find, items, non_abstract, register, size, unregister
Class Method Details
.item_klass ⇒ Object
33 34 35 |
# File 'lib/action_mcp/tools_registry.rb', line 33 def item_klass Tool end |
.tool_call(tool_name, arguments, _metadata = {}) ⇒ Hash
Calls a tool with the given name and arguments.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/action_mcp/tools_registry.rb', line 18 def tool_call(tool_name, arguments, = {}) tool_class = find(tool_name) tool = tool_class.new(arguments) tool.call rescue RegistryBase::NotFound error_response(:invalid_params, message: "Tool not found: #{tool_name}") rescue ArgumentError => e # Handle parameter validation errors error_response(:invalid_params, message: e.) rescue StandardError => e # FIXME, we should maybe not return the error message to the user error_response(:invalid_params, message: "Tool execution failed: #{e.}") end |