Class: Rasti::AI::MCP::Client
- Inherits:
-
Object
- Object
- Rasti::AI::MCP::Client
- Defined in:
- lib/rasti/ai/mcp/client.rb
Instance Method Summary collapse
- #call_tool(name, arguments = {}) ⇒ Object
-
#initialize(url:, allowed_tools: nil, logger: nil) ⇒ Client
constructor
A new instance of Client.
- #list_tools ⇒ Object
Constructor Details
Instance Method Details
#call_tool(name, arguments = {}) ⇒ Object
22 23 24 25 26 |
# File 'lib/rasti/ai/mcp/client.rb', line 22 def call_tool(name, arguments={}) raise "Invalid tool: #{name}" if allowed_tools && !allowed_tools.include?(name) result = request_mcp 'tools/call', name: name, arguments: arguments JSON.dump result['content'][0] end |
#list_tools ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/rasti/ai/mcp/client.rb', line 12 def list_tools result = request_mcp 'tools/list' tools = result['tools'] if allowed_tools tools.select { |tool| allowed_tools.include? tool['name'] } else tools end end |