Skip to main content
Glama
PaulieB14

graph-polymarket-mcp

get_live_prices

Fetch the current best buy or sell price for Polymarket outcome tokens using CLOB token IDs from search_markets or get_market_info.

Instructions

Get real-time CLOB prices for Polymarket outcome tokens. Returns the current best price for buying or selling. Token IDs come from: clobTokenIds in search_markets/get_market_info, or token_id in get_clob_market.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tokenIdsYesArray of CLOB token IDs (get these from search_markets or get_market_info clobTokenIds field)
sideNoPrice side: buy or sellbuy

Implementation Reference

  • src/index.ts:1118-1147 (registration)
    Registration of the 'get_live_prices' tool. Calls getClobPrice for a single tokenId or getClobPricesBatch for multiple tokenIds from the polymarketApi module.
    // ---------------------------------------------------------------------------
    // Tool 25: get_live_prices
    // ---------------------------------------------------------------------------
    server.registerTool(
      "get_live_prices",
      {
        description:
          "Get real-time CLOB prices for Polymarket outcome tokens. Returns the current best price for buying or selling. Token IDs come from: clobTokenIds in search_markets/get_market_info, or token_id in get_clob_market.",
        inputSchema: {
          tokenIds: z
            .array(z.string())
            .min(1)
            .max(20)
            .describe("Array of CLOB token IDs (get these from search_markets or get_market_info clobTokenIds field)"),
          side: z.enum(["buy", "sell"]).default("buy").describe("Price side: buy or sell"),
        },
      },
      async ({ tokenIds, side }) => {
        try {
          if (tokenIds.length === 1) {
            const result = await getClobPrice(tokenIds[0], side);
            return textResult({ tokenId: tokenIds[0], side, ...result });
          }
          const result = await getClobPricesBatch(tokenIds, side);
          return textResult({ side, prices: result });
        } catch (error) {
          return errorResult(error);
        }
      }
    );
  • Handler function getClobPrice: fetches a single CLOB price from the Polymarket CLOB API for a given token ID and side (buy/sell).
    export async function getClobPrice(
      tokenId: string,
      side: "buy" | "sell" = "buy"
    ): Promise<{ price: string }> {
      return fetchJson<{ price: string }>(
        `${CLOB_BASE}/price?token_id=${encodeURIComponent(tokenId)}&side=${side}`
      );
    }
  • Handler function getClobPricesBatch: fetches CLOB prices for multiple token IDs from the Polymarket CLOB API batch endpoint.
    export async function getClobPricesBatch(
      tokenIds: string[],
      side: "buy" | "sell" = "buy"
    ): Promise<unknown> {
      const params = tokenIds.map((id) => `token_ids=${encodeURIComponent(id)}`).join("&");
      return fetchJson<unknown>(`${CLOB_BASE}/prices?${params}&side=${side}`);
    }
  • Helper function fetchJson: generic JSON fetcher used by all CLOB API functions to make HTTP requests.
    async function fetchJson<T>(url: string): Promise<T> {
      const response = await fetch(url, {
        headers: { Accept: "application/json" },
      });
      if (!response.ok) {
        throw new PolymarketApiError(
          `HTTP ${response.status}: ${response.statusText}`,
          response.status,
          url
        );
      }
      return response.json() as Promise<T>;
    }
  • Type definition for ClobPrice used in price responses.
    export interface ClobPrice {
      price: string;
      size: string;
    }
Behavior4/5

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

Since no annotations are provided, the description carries the full burden. It discloses the tool returns the current best price for a given side, which is a read operation. It does not detail response format or error handling, but the core behavior is clear.

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 efficient sentences with no wasted words. The first sentence states the purpose, the second explains input sourcing. Perfectly front-loaded.

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?

For a simple tool with 2 params and no output schema, the description is adequate but incomplete. It does not specify the return format or any edge cases. Siblings with more complex output might set a higher bar, but for this tool it is minimally viable.

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?

Schema description coverage is 100%, so baseline is 3. The description adds extra context on where to obtain token IDs (search_markets/get_market_info, get_clob_market), which aids usage beyond the schema.

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 the tool gets real-time CLOB prices for Polymarket outcome tokens and returns the best price for buying or selling. It specifies the source of token IDs, distinguishing it from siblings like get_live_orderbook and get_price_history.

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

Usage Guidelines4/5

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

The description gives clear context on when to use the tool (real-time best price) and references related tools for obtaining token IDs. However, it does not explicitly mention when not to use it or alternatives for full order book data.

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