Skip to main content
Glama
PaulieB14

graph-polymarket-mcp

get_orderbook_trades

Retrieve recent filled orders from the Polymarket orderbook subgraph, with optional filters by maker or taker address.

Instructions

Get recent order fills from the Orderbook subgraph

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
firstNoNumber of trades to return
makerNoOptional: filter by maker address
takerNoOptional: filter by taker address

Implementation Reference

  • src/index.ts:349-387 (registration)
    Registration of the 'get_orderbook_trades' MCP tool with input schema using Zod validation. Defines the tool name, description, input parameters (first, maker, taker), and handler function.
    server.registerTool(
      "get_orderbook_trades",
      {
        description: "Get recent order fills from the Orderbook subgraph",
        inputSchema: {
          first: z.number().min(1).max(100).default(20).describe("Number of trades to return"),
          maker: z.string().optional().describe("Optional: filter by maker address"),
          taker: z.string().optional().describe("Optional: filter by taker address"),
        },
      },
      async ({ first, maker, taker }) => {
        try {
          const filters: string[] = [];
          if (maker) filters.push(`maker: "${maker.toLowerCase()}"`);
          if (taker) filters.push(`taker: "${taker.toLowerCase()}"`);
          const where = filters.length > 0 ? `, where: { ${filters.join(", ")} }` : "";
    
          const query = `{
            orderFilledEvents(first: ${first}, orderBy: timestamp, orderDirection: desc${where}) {
              id
              maker
              taker
              makerAssetId
              takerAssetId
              makerAmountFilled
              takerAmountFilled
              fee
              price
              side
              timestamp
            }
          }`;
          const data = await querySubgraph(SUBGRAPHS.orderbook.ipfsHash, query);
          return textResult(data);
        } catch (error) {
          return errorResult(error);
        }
      }
    );
  • Handler function for get_orderbook_trades. Constructs a GraphQL query to fetch orderFilledEvents from the Orderbook subgraph, with optional maker/taker filters, and returns the results. The entire tool registration (lines 349-387) is both the registration and the handler inline.
      async ({ first, maker, taker }) => {
        try {
          const filters: string[] = [];
          if (maker) filters.push(`maker: "${maker.toLowerCase()}"`);
          if (taker) filters.push(`taker: "${taker.toLowerCase()}"`);
          const where = filters.length > 0 ? `, where: { ${filters.join(", ")} }` : "";
    
          const query = `{
            orderFilledEvents(first: ${first}, orderBy: timestamp, orderDirection: desc${where}) {
              id
              maker
              taker
              makerAssetId
              takerAssetId
              makerAmountFilled
              takerAmountFilled
              fee
              price
              side
              timestamp
            }
          }`;
          const data = await querySubgraph(SUBGRAPHS.orderbook.ipfsHash, query);
          return textResult(data);
        } catch (error) {
          return errorResult(error);
        }
      }
    );
Behavior3/5

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

With no annotations, the description carries full burden. It implies a read operation but does not disclose details such as rate limits, pagination, or what 'recent' means in terms of time window.

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

Conciseness3/5

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

The description is a single sentence, which is concise but not particularly informative. It could include more context without becoming verbose.

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

Completeness2/5

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

Given the low complexity and no output schema, the description is insufficient. It does not specify timeframes, result format, or how to interpret 'recent'. More context would be helpful, especially with many sibling tools.

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?

Although schema description coverage is 100%, the description does not add any additional meaning beyond what the schema already provides. The baseline of 3 is appropriate.

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

Purpose4/5

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

The description clearly states that the tool retrieves recent order fills from the Orderbook subgraph, using a specific verb and resource. While it distinguishes itself from siblings like get_last_trade or get_live_orderbook, it could be more explicit about the scope.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives like get_last_trade or get_live_orderbook. The agent lacks context to make an informed selection.

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