Class: GrowwMcp::Tools::SearchInstruments

Inherits:
BaseTool
  • Object
show all
Defined in:
lib/groww_mcp/tools/instrument_tools.rb

Class Method Summary collapse

Class Method Details

.call(server_context:, query:, limit: 20) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/groww_mcp/tools/instrument_tools.rb', line 28

def call(server_context:, query:, limit: 20)
  client = server_context[:client]
  result = client.search_instruments(query, limit: limit)
  if result.empty?
    return MCP::Tool::Response.new([{ type: "text", text: "No instruments matched '#{query}'." }])
  end

  format_response(result)
rescue GrowwMcp::ApiError => e
  error_response(e)
end