Skip to main content
Glama
darved2305

groww-mcp

by darved2305

get_ohlc_data

Retrieve OHLC (Open, High, Low, Close) price data for stocks with customizable time intervals to analyze market trends and inform investment decisions.

Instructions

OHLC candles for a symbol — supports 1d/1w/1m/1y intervals

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesStock symbol
exchangeNoExchangeNSE
intervalNoCandle interval1d

Implementation Reference

  • The handler and tool registration for 'get_ohlc_data'. It fetches OHLC data using growwClient.getOHLC and formats it into a text response for the MCP client.
    // ── get_ohlc_data ─────────────────────────────────────────
    server.tool(
      "get_ohlc_data",
      "OHLC candles for a symbol — supports 1d/1w/1m/1y intervals",
      {
        symbol: z.string().describe("Stock symbol"),
        exchange: z.enum(["NSE", "BSE"]).default("NSE").describe("Exchange"),
        interval: z.enum(["1d", "1w", "1m", "1y"]).default("1d").describe("Candle interval"),
      },
      async ({ symbol, exchange, interval }) => {
        try {
          const sym = normalizeSymbol(symbol);
          const candles = await growwClient.getOHLC(sym, exchange, interval);
          if (candles.length === 0) return mcpText(`📭 No OHLC data for ${sym}`);
    
          const header = `📊 ${sym}.${exchange} — OHLC (${interval})\n${"─".repeat(55)}\n${"Date".padEnd(12)} ${"Open".padStart(10)} ${"High".padStart(10)} ${"Low".padStart(10)} ${"Close".padStart(10)} ${"Vol".padStart(8)}`;
    
          const rows = candles.slice(-15).map((c) => {
            const d = c.timestamp.substring(0, 10);
            return `${d.padEnd(12)} ${c.open.toFixed(2).padStart(10)} ${c.high.toFixed(2).padStart(10)} ${c.low.toFixed(2).padStart(10)} ${c.close.toFixed(2).padStart(10)} ${formatVolume(c.volume).padStart(8)}`;
          });
    
          const note = candles.length > 15 ? `\n(showing last 15 of ${candles.length} candles)` : "";
          return mcpText([header, ...rows, note].join("\n"));
        } catch (err) {
          return mcpError(normalizeError(err));
        }
      }
    );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/darved2305/groww-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server