Skip to main content
Glama
darved2305

groww-mcp

by darved2305

get_order_history

Retrieve past order details and status from your Groww account, with optional filtering by date range to track transaction history.

Instructions

Past orders with status, optionally filter by date range

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_dateNoStart date (YYYY-MM-DD)
end_dateNoEnd date (YYYY-MM-DD)

Implementation Reference

  • Tool registration and handler implementation for get_order_history.
    server.tool(
      "get_order_history",
      "Past orders with status, optionally filter by date range",
      {
        start_date: z.string().optional().describe("Start date (YYYY-MM-DD)"),
        end_date: z.string().optional().describe("End date (YYYY-MM-DD)"),
      },
      async ({ start_date, end_date }) => {
        try {
          const orders = await growwClient.getOrderHistory(start_date, end_date);
          if (orders.length === 0) return mcpText("📭 No orders found for the given period.");
    
          const statusEmoji: Record<string, string> = {
            EXECUTED: "✅", PENDING: "⏳", CANCELLED: "❌", REJECTED: "🚫", PARTIAL: "🔶",
          };
    
          const lines = orders.map((o) => {
            const emoji = statusEmoji[o.status] || "❓";
            return [
              `${emoji} ${o.orderId} — ${o.orderType} ${o.symbol}.${o.exchange}`,
              `   ${o.priceType} / ${o.productType}  |  Qty: ${o.quantity}  |  Price: ${o.price > 0 ? formatCurrencyExact(o.price) : "MARKET"}`,
              `   Status: ${o.status}${o.filledQuantity > 0 ? ` (filled ${o.filledQuantity} @ ${formatCurrencyExact(o.avgFilledPrice)})` : ""}`,
              `   ${new Date(o.timestamp).toLocaleString("en-IN", { timeZone: "Asia/Kolkata" })}${o.remarks ? ` — ${o.remarks}` : ""}`,
            ].join("\n");
          });
    
          const header = `📋 ORDER HISTORY (${orders.length} orders)\n${"─".repeat(50)}`;
          return mcpText([header, ...lines].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