Class: GrowwMcp::Tools::GetHistoricalData

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

Class Method Summary collapse

Class Method Details

.call(server_context:, trading_symbol:, start_time:, end_time:, exchange: "NSE", segment: "CASH", interval_in_minutes: nil) ⇒ Object



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/groww_mcp/tools/market_tools.rb', line 189

def call(server_context:, trading_symbol:, start_time:, end_time:, exchange: "NSE", segment: "CASH",
         interval_in_minutes: nil)
  client = server_context[:client]
  result = client.historical_candles(trading_symbol, start_time, end_time,
                                     exchange: exchange, segment: segment,
                                     interval_in_minutes: interval_in_minutes)
  format_response(result)
rescue GrowwMcp::ForbiddenError
  MCP::Tool::Response.new([{
    type: "text",
    text: "❌ Historical Data access denied. Requires Groww Live Data subscription (₹499 + GST/month).",
  }])
rescue GrowwMcp::ApiError => e
  error_response(e)
end