Class: GrowwMcp::Tools::GetOHLC

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

Class Method Summary collapse

Class Method Details

.call(server_context:, symbols:, exchange: "NSE", segment: "CASH") ⇒ Object



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/groww_mcp/tools/market_tools.rb', line 128

def call(server_context:, symbols:, exchange: "NSE", segment: "CASH")
  if symbols.length > 50
    return MCP::Tool::Response.new([{ type: "text", text: "❌ Maximum 50 symbols allowed per request." }])
  end

  client = server_context[:client]
  result = client.ohlc(symbols, exchange: exchange, segment: segment)
  format_response(result)
rescue GrowwMcp::ForbiddenError
  MCP::Tool::Response.new([{
    type: "text",
    text: "❌ Live Data access denied. Requires Groww Live Data subscription (₹499 + GST/month).",
  }])
rescue GrowwMcp::ApiError => e
  error_response(e)
end