Skip to main content
Glama
PaulieB14

graph-polymarket-mcp

get_top_traders

Retrieve top Polymarket traders ranked by realized P&L, win rate, or volume. Filter by minimum trades and limit results.

Instructions

Get the top Polymarket traders ranked by realized P&L, win rate, or volume from the Beefy P&L subgraph.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
firstNoNumber of traders to return (1-100)
orderByNoMetric to rank traders bytotalRealizedPnl
minTradesNoMinimum number of trades to filter out inactive accounts

Implementation Reference

  • src/index.ts:472-543 (registration)
    Registration of the 'get_top_traders' tool via server.registerTool with name 'get_top_traders'.
    // Tool 11: get_top_traders
    // ---------------------------------------------------------------------------
    server.registerTool(
      "get_top_traders",
      {
        description:
          "Get the top Polymarket traders ranked by realized P&L, win rate, or volume from the Beefy P&L subgraph.",
        inputSchema: {
          first: z.number().min(1).max(100).default(10).describe("Number of traders to return (1-100)"),
          orderBy: z
            .enum(["totalRealizedPnl", "collateralVolume", "winRate", "profitFactor", "numTrades"])
            .default("totalRealizedPnl")
            .describe("Metric to rank traders by"),
          minTrades: z
            .number()
            .min(1)
            .default(10)
            .describe("Minimum number of trades to filter out inactive accounts"),
        },
      },
      async ({ first, orderBy, minTrades }) => {
        try {
          const beefyQuery = `{
            accounts(
              first: ${first},
              orderBy: ${orderBy},
              orderDirection: desc,
              where: { numTrades_gte: "${minTrades}" }
            ) {
              id numTrades collateralVolume totalRealizedPnl totalUnrealizedPnl
              totalFeesPaid winRate profitFactor maxDrawdown
              numWinningPositions numLosingPositions lastTradedTimestamp
            }
          }`;
          // Fetch top OB-volume accounts to surface OB-only traders absent from Beefy rankings
          const obQuery = `{
            accounts(first: ${first}, orderBy: totalVolume, orderDirection: desc) {
              id totalVolume tradesQuantity
            }
          }`;
          const [beefyData, obData] = await Promise.all([
            querySubgraph(SUBGRAPHS.beefy_pnl.ipfsHash, beefyQuery),
            querySubgraph(SUBGRAPHS.orderbook.ipfsHash, obQuery).catch(() => null),
          ]);
          const bd = beefyData as { accounts?: Array<{ id: string; collateralVolume?: string }> };
          const od = obData as { accounts?: Array<{ id: string; totalVolume: string; tradesQuantity: string }> } | null;
          const beefyIds = new Set((bd.accounts ?? []).map((a) => a.id));
          const obById = new Map((od?.accounts ?? []).map((a) => [a.id, a]));
          // Flag beefy rows where OB-tracked volume significantly exceeds Beefy-tracked volume
          const annotated = (bd.accounts ?? []).map((a) => {
            const ob = obById.get(a.id);
            const beefyVol = parseFloat(a.collateralVolume || "0");
            const obVol = ob ? parseFloat(ob.totalVolume) : null;
            const flag =
              obVol !== null && obVol > beefyVol * 1.5 && obVol - beefyVol > 1000
                ? `⚠ OB volume ($${obVol.toFixed(0)}) exceeds Beefy-tracked volume ($${beefyVol.toFixed(0)}) — P&L ranking may be incomplete`
                : undefined;
            return { ...a, ...(flag ? { reliabilityWarning: flag } : {}) };
          });
          // Surface high-volume OB traders completely absent from Beefy leaderboard
          const obOnlyTraders = (od?.accounts ?? [])
            .filter((a) => !beefyIds.has(a.id))
            .map((a) => ({ address: a.id, obVolume: a.totalVolume, obTrades: a.tradesQuantity, note: "not tracked by Beefy P&L subgraph — P&L unavailable" }));
          return textResult({
            traders: annotated,
            ...(obOnlyTraders.length > 0 ? { obOnlyTradersNotInLeaderboard: obOnlyTraders } : {}),
          });
        } catch (error) {
          return errorResult(error);
        }
      }
    );
  • Handler function for get_top_traders. Queries the Beefy P&L subgraph for top traders ranked by totalRealizedPnl (or other metrics), cross-references with Orderbook subgraph to detect OB-only traders and flag incomplete P&L rankings.
      async ({ first, orderBy, minTrades }) => {
        try {
          const beefyQuery = `{
            accounts(
              first: ${first},
              orderBy: ${orderBy},
              orderDirection: desc,
              where: { numTrades_gte: "${minTrades}" }
            ) {
              id numTrades collateralVolume totalRealizedPnl totalUnrealizedPnl
              totalFeesPaid winRate profitFactor maxDrawdown
              numWinningPositions numLosingPositions lastTradedTimestamp
            }
          }`;
          // Fetch top OB-volume accounts to surface OB-only traders absent from Beefy rankings
          const obQuery = `{
            accounts(first: ${first}, orderBy: totalVolume, orderDirection: desc) {
              id totalVolume tradesQuantity
            }
          }`;
          const [beefyData, obData] = await Promise.all([
            querySubgraph(SUBGRAPHS.beefy_pnl.ipfsHash, beefyQuery),
            querySubgraph(SUBGRAPHS.orderbook.ipfsHash, obQuery).catch(() => null),
          ]);
          const bd = beefyData as { accounts?: Array<{ id: string; collateralVolume?: string }> };
          const od = obData as { accounts?: Array<{ id: string; totalVolume: string; tradesQuantity: string }> } | null;
          const beefyIds = new Set((bd.accounts ?? []).map((a) => a.id));
          const obById = new Map((od?.accounts ?? []).map((a) => [a.id, a]));
          // Flag beefy rows where OB-tracked volume significantly exceeds Beefy-tracked volume
          const annotated = (bd.accounts ?? []).map((a) => {
            const ob = obById.get(a.id);
            const beefyVol = parseFloat(a.collateralVolume || "0");
            const obVol = ob ? parseFloat(ob.totalVolume) : null;
            const flag =
              obVol !== null && obVol > beefyVol * 1.5 && obVol - beefyVol > 1000
                ? `⚠ OB volume ($${obVol.toFixed(0)}) exceeds Beefy-tracked volume ($${beefyVol.toFixed(0)}) — P&L ranking may be incomplete`
                : undefined;
            return { ...a, ...(flag ? { reliabilityWarning: flag } : {}) };
          });
          // Surface high-volume OB traders completely absent from Beefy leaderboard
          const obOnlyTraders = (od?.accounts ?? [])
            .filter((a) => !beefyIds.has(a.id))
            .map((a) => ({ address: a.id, obVolume: a.totalVolume, obTrades: a.tradesQuantity, note: "not tracked by Beefy P&L subgraph — P&L unavailable" }));
          return textResult({
            traders: annotated,
            ...(obOnlyTraders.length > 0 ? { obOnlyTradersNotInLeaderboard: obOnlyTraders } : {}),
          });
        } catch (error) {
          return errorResult(error);
        }
      }
    );
  • Input schema for get_top_traders: 'first' (1-100, default 10), 'orderBy' (enum of metrics like totalRealizedPnl, collateralVolume, winRate, profitFactor, numTrades), and 'minTrades' (minimum trade count filter, default 10).
      inputSchema: {
        first: z.number().min(1).max(100).default(10).describe("Number of traders to return (1-100)"),
        orderBy: z
          .enum(["totalRealizedPnl", "collateralVolume", "winRate", "profitFactor", "numTrades"])
          .default("totalRealizedPnl")
          .describe("Metric to rank traders by"),
        minTrades: z
          .number()
          .min(1)
          .default(10)
          .describe("Minimum number of trades to filter out inactive accounts"),
      },
    },
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, and description only states the core functionality without disclosing behavioral traits like pagination limits, data freshness, or rate limits. For a read-only aggregation tool, minimal transparency beyond schema is offered.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence, front-loaded with verb and resource, no extraneous information. Efficiently conveys the tool's purpose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple list tool with only three optional parameters and no output schema, the description covers the main functionality. It could mention return format or query source, but overall is complete for the scope.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Input schema covers all three parameters with descriptions, and the description mentions ranking metrics aligning with the orderBy enum. However, description adds no new meaning beyond schema; baseline 3 appropriate due to high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states the tool retrieves top Polymarket traders ranked by specific metrics like realized P&L, win rate, or volume. It specifies the source (Beefy P&L subgraph) and differentiates from sibling tools focused on individual account data or market details.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Description does not provide explicit guidance on when to use this tool versus alternatives such as get_trader_profile or get_account_pnl. Usage is implied but not explicitly contrasted with siblings, leaving the agent to infer context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/PaulieB14/graph-polymarket-mcp'

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