Skip to main content
Glama
darved2305

groww-mcp

by darved2305

get_positions

Retrieve current intraday open positions with unrealized profit and loss data for equity holdings on Groww.

Instructions

Intraday open positions with unrealized P&L

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The MCP tool handler for 'get_positions' which calls the Groww client and formats the response for the MCP server.
    // ── get_positions ─────────────────────────────────────────
    server.tool(
      "get_positions",
      "Intraday open positions with unrealized P&L",
      {},
      async () => {
        try {
          const positions = await growwClient.getPositions();
          if (positions.length === 0) return mcpText("📭 No open positions today.");
    
          const lines = positions.map((p) => {
            const emoji = pnlEmoji(p.pnl);
            return [
              `${emoji} ${p.symbol}.${p.exchange} [${p.orderType} / ${p.productType}]`,
              `   Qty: ${p.quantity}  |  Buy: ${formatCurrencyExact(p.buyPrice)}  |  LTP: ${formatCurrencyExact(p.currentPrice)}`,
              `   Unrealized P&L: ${pnlSign(p.pnl)} (${formatPercent(p.pnlPercent)})`,
            ].join("\n");
          });
    
          const header = `⚡ OPEN POSITIONS (${positions.length})\n${"─".repeat(50)}`;
          return mcpText([header, ...lines, `\nAs of ${nowIST()}`].join("\n\n"));
        } catch (err) {
          return mcpError(normalizeError(err));
        }
      }
    );
  • The client method that fetches position data from the API or mock data.
    async getPositions(): Promise<Position[]> {
      if (isMockMode()) return MOCK.positions();
      return this.request<Position[]>("GET", "/portfolio/positions");
    }

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