Class: ActiveMcp::Server::ToolManager
- Inherits:
-
Object
- Object
- ActiveMcp::Server::ToolManager
- Defined in:
- lib/active_mcp/server/tool_manager.rb
Instance Attribute Summary collapse
-
#tools ⇒ Object
readonly
Returns the value of attribute tools.
Instance Method Summary collapse
- #call_tool(name, arguments = {}) ⇒ Object
-
#initialize(uri: nil, auth: nil) ⇒ ToolManager
constructor
A new instance of ToolManager.
- #load_registered_tools ⇒ Object
Constructor Details
#initialize(uri: nil, auth: nil) ⇒ ToolManager
Returns a new instance of ToolManager.
8 9 10 11 12 13 14 15 |
# File 'lib/active_mcp/server/tool_manager.rb', line 8 def initialize(uri: nil, auth: nil) @tools = {} @uri = uri if auth @auth_header = "#{auth[:type] == :bearer ? "Bearer" : "Basic"} #{auth[:token]}" end end |
Instance Attribute Details
#tools ⇒ Object (readonly)
Returns the value of attribute tools.
6 7 8 |
# File 'lib/active_mcp/server/tool_manager.rb', line 6 def tools @tools end |
Instance Method Details
#call_tool(name, arguments = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/active_mcp/server/tool_manager.rb', line 17 def call_tool(name, arguments = {}) tool_info = @tools.find { _1[:name] == name } unless tool_info return { isError: true, content: [{type: "text", text: "Tool not found: #{name}"}] } end invoke_tool(name, arguments) end |
#load_registered_tools ⇒ Object
30 31 32 |
# File 'lib/active_mcp/server/tool_manager.rb', line 30 def load_registered_tools fetch_tools end |