Skip to main content
Glama
PaulieB14

graph-polymarket-mcp

get_global_stats

Retrieve aggregated Polymarket platform statistics including total markets, volume, fees, and trades from combined subgraph data.

Instructions

Get aggregate Polymarket platform statistics. Combines market counts from the Main subgraph with accurate volume/fee/trade data from the Orderbook subgraph.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • src/index.ts:389-436 (registration)
    Tool registration for 'get_global_stats' — registers the tool with the MCP server using server.registerTool with no input schema, and defines the handler that queries both the Main subgraph for condition/trader counts and the Orderbook subgraph for authoritative volume/fee/trade data.
    // ---------------------------------------------------------------------------
    // Tool 9: get_global_stats
    // ---------------------------------------------------------------------------
    server.registerTool(
      "get_global_stats",
      {
        description:
          "Get aggregate Polymarket platform statistics. Combines market counts from the Main subgraph with accurate volume/fee/trade data from the Orderbook subgraph.",
      },
      async () => {
        try {
          // Main subgraph: reliable for condition/trader counts
          const mainQuery = `{
            globals {
              id
              numConditions
              numOpenConditions
              numClosedConditions
              numTraders
            }
          }`;
          // Orderbook subgraph: authoritative source for volume (main Global has zeroed volume fields)
          const orderbookQuery = `{
            ordersMatchedGlobals(first: 1) {
              id
              tradesQuantity
              buysQuantity
              sellsQuantity
              collateralVolume
              scaledCollateralVolume
              collateralBuyVolume
              scaledCollateralBuyVolume
              collateralSellVolume
              scaledCollateralSellVolume
              totalFees
              averageTradeSize
            }
          }`;
          const [mainData, orderbookData] = await Promise.all([
            querySubgraph(SUBGRAPHS.main.ipfsHash, mainQuery),
            querySubgraph(SUBGRAPHS.orderbook.ipfsHash, orderbookQuery),
          ]);
          return textResult({ markets: mainData, volume: orderbookData });
        } catch (error) {
          return errorResult(error);
        }
      }
    );
  • Handler function for 'get_global_stats' — executes the tool logic: queries the Main subgraph's 'globals' entity (numConditions, numOpenConditions, numClosedConditions, numTraders) and the Orderbook subgraph's 'ordersMatchedGlobals' entity (tradesQuantity, collateralVolume, totalFees, etc.) in parallel, then returns combined results.
    async () => {
      try {
        // Main subgraph: reliable for condition/trader counts
        const mainQuery = `{
          globals {
            id
            numConditions
            numOpenConditions
            numClosedConditions
            numTraders
          }
        }`;
        // Orderbook subgraph: authoritative source for volume (main Global has zeroed volume fields)
        const orderbookQuery = `{
          ordersMatchedGlobals(first: 1) {
            id
            tradesQuantity
            buysQuantity
            sellsQuantity
            collateralVolume
            scaledCollateralVolume
            collateralBuyVolume
            scaledCollateralBuyVolume
            collateralSellVolume
            scaledCollateralSellVolume
            totalFees
            averageTradeSize
          }
        }`;
        const [mainData, orderbookData] = await Promise.all([
          querySubgraph(SUBGRAPHS.main.ipfsHash, mainQuery),
          querySubgraph(SUBGRAPHS.orderbook.ipfsHash, orderbookQuery),
        ]);
        return textResult({ markets: mainData, volume: orderbookData });
      } catch (error) {
        return errorResult(error);
      }
    }
Behavior3/5

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

No annotations are provided. The description discloses the data source combination (Main and Orderbook subgraphs), which is behavioral context. However, it does not mention any side effects, auth needs, rate limits, or expected return structure. More transparency would be beneficial.

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?

Two sentences, front-loaded with purpose. No wasted words. Every sentence adds value: the first defines the action and scope, the second details the data source integration.

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

Completeness3/5

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

Given no output schema, the description should hint at return fields. It only says 'aggregate statistics' which is vague. Siblings like get_daily_stats are likely more specific. Missing key output details makes it incomplete.

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

Parameters4/5

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

There are no parameters, so schema description coverage is 100%. Baseline for 0 params is 4. The description adds no param info, but none is needed.

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?

The description clearly states 'Get aggregate Polymarket platform statistics' and distinguishes by specifying it combines data from Main and Orderbook subgraphs. Among siblings like get_market_info or get_account_pnl, this is the only global aggregate tool.

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?

The description implies use when overall platform stats are needed, but provides no explicit when-to-use or when-not-to-use guidance. No alternatives are mentioned, leaving the agent to infer context from sibling tool names.

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