Class: GrowwMcp::Tools::GetOptionChain

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

Class Method Summary collapse

Class Method Details

.call(server_context:, trading_symbol:, expiry_date:, exchange: "NSE") ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/groww_mcp/tools/option_chain_tools.rb', line 33

def call(server_context:, trading_symbol:, expiry_date:, exchange: "NSE")
  client = server_context[:client]
  result = client.option_chain(trading_symbol, expiry_date: expiry_date, exchange: exchange)
  format_response(result)
rescue GrowwMcp::ForbiddenError
  MCP::Tool::Response.new([{
    type: "text",
    text: "❌ Option Chain access denied. Requires Groww Live Data subscription (₹499 + GST/month). " \
          "Subscribe at: Groww App → Settings → Trading APIs.",
  }])
rescue GrowwMcp::ApiError => e
  error_response(e)
end