get_order_books
Retrieve order books for multiple Polymarket prediction market tokens in a single batch request to analyze market depth and liquidity.
Instructions
Get order books for multiple Polymarket tokens in a single batch request.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token_ids | Yes | Array of CLOB token IDs |
Implementation Reference
- src/tools/clob/orderbook.ts:25-46 (handler)The MCP tool "get_order_books" is registered here, which calls clob.getOrderBooks.
server.tool( "get_order_books", "Get order books for multiple Polymarket tokens in a single batch request.", { token_ids: z .array(z.string()) .min(1) .max(20) .describe("Array of CLOB token IDs"), }, async (args) => { try { const data = await clob.getOrderBooks(args.token_ids); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${(error as Error).message}` }], isError: true, }; } }, ); - src/api/clob.ts:44-46 (handler)This is the underlying API method used by the "get_order_books" tool.
async getOrderBooks(tokenIds: string[]): Promise<ClobOrderBook[]> { return this.client.clobPost<ClobOrderBook[]>("/books", tokenIds); }