Class: GrowwMcp::Tools::DownloadInstruments

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

Class Method Summary collapse

Class Method Details

.call(server_context:) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/groww_mcp/tools/instrument_tools.rb', line 95

def call(server_context:)
  client = server_context[:client]
  csv_data = client.download_instruments

  lines = csv_data.split("\n")
  sample = lines[0..20].join("\n")

  MCP::Tool::Response.new([{
    type: "text",
    text: "Total instruments: #{lines.length - 1}\n\nSample (first 20 rows):\n#{sample}",
  }])
rescue => e
  error_response(e)
end