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, re_register, register, size, unregister
Class Method Details
.item_klass ⇒ Object
38 39 40 |
# File 'lib/action_mcp/tools_registry.rb', line 38 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 32 33 34 35 36 |
# 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 # Hide error details in production to prevent information disclosure = if Rails.env.production? "Tool execution failed" else "Tool execution failed: #{e.message}" end error_response(:invalid_params, message: ) end |