Skip to main content
Glama
PaulieB14

graph-polymarket-mcp

get_live_spread

Retrieve real-time bid and ask prices for a Polymarket outcome token to calculate the spread, enabling assessment of market liquidity and trading costs.

Instructions

Get the real-time bid-ask spread for a Polymarket outcome token. Returns best bid, best ask, and spread. Useful for assessing market liquidity and trading costs.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
tokenIdYesCLOB token ID

Implementation Reference

  • src/index.ts:1152-1172 (registration)
    Registration of the 'get_live_spread' tool using server.registerTool. Defines the input schema (tokenId: string) and calls getClobSpread + getClobMidpoint helper functions.
    server.registerTool(
      "get_live_spread",
      {
        description:
          "Get the real-time bid-ask spread for a Polymarket outcome token. Returns best bid, best ask, and spread. Useful for assessing market liquidity and trading costs.",
        inputSchema: {
          tokenId: z.string().describe("CLOB token ID"),
        },
      },
      async ({ tokenId }) => {
        try {
          const [spread, midpoint] = await Promise.all([
            getClobSpread(tokenId),
            getClobMidpoint(tokenId),
          ]);
          return textResult({ tokenId, ...spread, midpoint: midpoint.mid });
        } catch (error) {
          return errorResult(error);
        }
      }
    );
  • Handler function for get_live_spread. Calls getClobSpread(tokenId) and getClobMidpoint(tokenId) in parallel, then returns the spread, bid, ask, and midpoint.
    async ({ tokenId }) => {
      try {
        const [spread, midpoint] = await Promise.all([
          getClobSpread(tokenId),
          getClobMidpoint(tokenId),
        ]);
        return textResult({ tokenId, ...spread, midpoint: midpoint.mid });
      } catch (error) {
        return errorResult(error);
      }
    }
  • The getClobSpread helper function that fetches the bid-ask spread from the CLOB API at /spread?token_id={tokenId}. Returns { spread, bid, ask }.
    export async function getClobSpread(
      tokenId: string
    ): Promise<{ spread: string; bid: string; ask: string }> {
      return fetchJson<{ spread: string; bid: string; ask: string }>(
        `${CLOB_BASE}/spread?token_id=${encodeURIComponent(tokenId)}`
      );
    }
  • The getClobMidpoint helper function that fetches the midpoint price from the CLOB API at /midpoint?token_id={tokenId}. Returns { mid }.
    export async function getClobMidpoint(tokenId: string): Promise<{ mid: string }> {
      return fetchJson<{ mid: string }>(
        `${CLOB_BASE}/midpoint?token_id=${encodeURIComponent(tokenId)}`
      );
    }
  • Input schema for get_live_spread tool: a single required string parameter 'tokenId' representing the CLOB token ID.
    inputSchema: {
      tokenId: z.string().describe("CLOB token ID"),
    },
Behavior3/5

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

No annotations are provided, so the description carries full responsibility for behavioral disclosure. It accurately states the tool returns real-time data, but does not mention potential latency, refresh rates, or whether it is a snapshot vs. streaming. For a simple read operation, this is adequate but could be improved.

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?

The description consists of two concise sentences: the first states the function, the second lists returned data and use case. Every word is informative with no redundancy or unnecessary detail.

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

Completeness5/5

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

Given the tool's low complexity (one parameter, no output schema, no annotations), the description sufficiently covers what the tool does, what it returns, and its purpose. No obvious gaps exist for an agent to effectively use this tool.

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?

The single parameter tokenId is described in the input schema as 'CLOB token ID', and the description adds no further explanation. With 100% schema description coverage, the baseline is 3, and the description does not provide additional semantics beyond what the schema already conveys.

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 retrieves the real-time bid-ask spread for a Polymarket outcome token, specifying returned fields (best bid, best ask, spread). It is distinct from sibling tools like get_live_orderbook or get_last_trade, as it focuses on the spread rather than full order book depths or individual trades.

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 notes the tool is useful for assessing market liquidity and trading costs, implying when to use it. However, it does not contrast with alternatives such as get_live_orderbook or get_last_trade, nor does it specify when not to use this tool (e.g., if full order book detail is needed).

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