Polymarket Market Depth
pm_micro_depthAnalyzes Polymarket order book depth and bid-ask spread to show liquidity and spread width for assessing market conditions.
Instructions
Get market depth and bid-ask spread analysis for Polymarket markets. Shows order book depth, spread width, and liquidity at various price levels. Cost: $0.003 per query. Source: Polymarket order book analysis.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| market_id | No | Market ID to analyze | |
| min_liquidity | No | Minimum liquidity in USD | |
| limit | No | Maximum results (default 25) |
Implementation Reference
- src/tools/pm_micro.ts:57-85 (handler)The async handler function for pm_micro_depth tool. Calls API endpoint /api/v1/pm/micro/depth with market_id, min_liquidity, and limit parameters, then returns formatted results.
async ({ market_id, min_liquidity, limit }) => { const res = await apiGet<PmMicroQueryResponse>("/api/v1/pm/micro/depth", { market_id, min_liquidity, limit: limit ?? 25, }); if (!res.ok) { return { content: [ { type: "text" as const, text: `API error (${res.status}): ${JSON.stringify(res.data)}`, }, ], isError: true, }; } const { count, data } = res.data; const warn = stalenessWarning(res); const summary = `${warn}Found ${count} market depth record(s).`; const json = JSON.stringify(data, null, 2); return { content: [{ type: "text" as const, text: `${summary}\n\n${json}` }], }; }, ); - src/tools/pm_micro.ts:39-55 (schema)Input schema for pm_micro_depth tool: optional market_id (string), optional min_liquidity (number), optional limit (int 1-100, default 25).
inputSchema: { market_id: z .string() .optional() .describe("Market ID to analyze"), min_liquidity: z .number() .optional() .describe("Minimum liquidity in USD"), limit: z .number() .int() .min(1) .max(100) .optional() .describe("Maximum results (default 25)"), }, - src/tools/pm_micro.ts:31-85 (registration)Registration of pm_micro_depth tool via server.registerTool() with name, metadata, inputSchema, and handler callback.
server.registerTool( "pm_micro_depth", { title: "Polymarket Market Depth", description: "Get market depth and bid-ask spread analysis for Polymarket markets. Shows " + "order book depth, spread width, and liquidity at various price levels. " + "Cost: $0.003 per query. Source: Polymarket order book analysis.", inputSchema: { market_id: z .string() .optional() .describe("Market ID to analyze"), min_liquidity: z .number() .optional() .describe("Minimum liquidity in USD"), limit: z .number() .int() .min(1) .max(100) .optional() .describe("Maximum results (default 25)"), }, }, async ({ market_id, min_liquidity, limit }) => { const res = await apiGet<PmMicroQueryResponse>("/api/v1/pm/micro/depth", { market_id, min_liquidity, limit: limit ?? 25, }); if (!res.ok) { return { content: [ { type: "text" as const, text: `API error (${res.status}): ${JSON.stringify(res.data)}`, }, ], isError: true, }; } const { count, data } = res.data; const warn = stalenessWarning(res); const summary = `${warn}Found ${count} market depth record(s).`; const json = JSON.stringify(data, null, 2); return { content: [{ type: "text" as const, text: `${summary}\n\n${json}` }], }; }, ); - src/index.ts:31-58 (registration)Import of registerPmMicroTools function from pm_micro.ts module (used to register all pm_micro tools on the server).
import { registerPmMicroTools } from "./tools/pm_micro.js"; function createMcpServer() { const server = new McpServer({ name: "verilex-data", version: "0.3.3", }); registerNpiTools(server); registerSecTools(server); registerPacerTools(server); registerWeatherTools(server); registerOtcTools(server); registerTrademarkTools(server); registerPatentTools(server); registerCompanyTools(server); registerCryptoTools(server); registerSanctionsTools(server); registerWhaleTools(server); registerLabelTools(server); registerHolderTools(server); registerDexTools(server); registerContractTools(server); registerPmTools(server); registerPmArbTools(server); registerPmResolutionTools(server); registerEconTools(server); registerPmMicroTools(server); - src/client.ts:35-41 (helper)The stalenessWarning helper used by the handler to check if returned data is stale.
export function stalenessWarning(res: ApiResponse): string { if (!res.stale) return ""; const parts = ["[STALE DATA]"]; if (res.lastUpdated) parts.push(`Last updated: ${res.lastUpdated}`); if (res.ageSeconds != null) parts.push(`Age: ${res.ageSeconds}s`); return parts.join(" ") + "\n\n"; }