Skip to main content
Glama
darved2305

groww-mcp

by darved2305

get_holdings

Fetch current equity holdings with average buy price, current value, and profit/loss percentage to track investment performance.

Instructions

Fetch all current equity holdings with avg buy price, current value, P&L %

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The "get_holdings" tool is registered and implemented within `registerPortfolioTools` in `src/tools/portfolio.ts`. It fetches holdings data from the `growwClient` and formats it into a text response for the MCP server.
    // ── get_holdings ──────────────────────────────────────────
    server.tool(
      "get_holdings",
      "Fetch all current equity holdings with avg buy price, current value, P&L %",
      {},
      async () => {
        try {
          const holdings = await growwClient.getHoldings();
          if (holdings.length === 0) return mcpText("📭 No holdings found. Your portfolio is empty.");
    
          const lines = holdings.map((h) => {
            const emoji = pnlEmoji(h.pnl);
            return [
              `${emoji} ${h.symbol}.${h.exchange} — ${h.name}`,
              `   Qty: ${h.quantity}  |  Avg: ${formatCurrencyExact(h.avgBuyPrice)}  |  LTP: ${formatCurrencyExact(h.currentPrice)}`,
              `   Invested: ${formatCurrency(h.investedValue)}  |  Current: ${formatCurrency(h.currentValue)}`,
              `   P&L: ${pnlSign(h.pnl)} (${formatPercent(h.pnlPercent)})  |  Day: ${pnlSign(h.dayChange)} (${formatPercent(h.dayChangePercent)})`,
            ].join("\n");
          });
    
          const header = `📊 YOUR HOLDINGS (${holdings.length} stocks)\n${"─".repeat(50)}`;
          const footer = `\nAs of ${nowIST()}`;
          return mcpText([header, ...lines, footer].join("\n\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