get_price
Retrieve the best available buy or sell price for a Polymarket prediction market token to inform trading decisions.
Instructions
Get the current price for a Polymarket token on the given side (buy or sell). Returns the best available price.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token_id | Yes | CLOB token ID (from market's clobTokenIds) | |
| side | Yes | Order side: buy or sell |
Implementation Reference
- src/tools/clob/prices.ts:13-23 (handler)The MCP tool handler for "get_price", which executes clob.getPrice().
async (args) => { try { const data = await clob.getPrice(args.token_id, args.side); 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/tools/clob/prices.ts:6-12 (registration)Registration of the "get_price" tool with its schema definition.
server.tool( "get_price", "Get the current price for a Polymarket token on the given side (buy or sell). Returns the best available price.", { token_id: z.string().describe("CLOB token ID (from market's clobTokenIds)"), side: z.enum(["buy", "sell"]).describe("Order side: buy or sell"), }, - src/api/clob.ts:17-22 (helper)The underlying API call implementation for fetching the price.
async getPrice(tokenId: string, side: "buy" | "sell"): Promise<ClobPrice> { return this.client.clob<ClobPrice>("/price", { token_id: tokenId, side, }); }