get_midpoint
Calculate the midpoint price for a Polymarket prediction market token by averaging the best bid and ask prices to determine fair market value.
Instructions
Get the midpoint price for a Polymarket token (average of best bid and ask).
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token_id | Yes | CLOB token ID |
Implementation Reference
- src/api/clob.ts:24-28 (handler)The actual implementation of the getMidpoint API call that fetches data from the CLOB endpoint.
async getMidpoint(tokenId: string): Promise<ClobMidpoint> { return this.client.clob<ClobMidpoint>("/midpoint", { token_id: tokenId, }); } - src/tools/clob/prices.ts:26-43 (registration)Registration and MCP tool handler for "get_midpoint", which calls the clob.getMidpoint method.
server.tool( "get_midpoint", "Get the midpoint price for a Polymarket token (average of best bid and ask).", { token_id: z.string().describe("CLOB token ID"), }, async (args) => { try { const data = await clob.getMidpoint(args.token_id); return { content: [{ type: "text", text: JSON.stringify(data, null, 2) }] }; } catch (error) { return { content: [{ type: "text", text: `Error: ${(error as Error).message}` }], isError: true, }; } }, );