get_market_stats
Retrieve aggregate statistics across prediction markets including totals, categories, sources, and trading volume for market overview and portfolio allocation decisions.
Instructions
Get aggregate statistics across all prediction markets — totals, categories, sources, and volume.
Returns total market count, active markets, category distribution, source breakdown (Kalshi vs Polymarket), and aggregate trading volume. Use for market overview, portfolio allocation decisions, or understanding the prediction market landscape.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- worker/src/tools.ts:572-585 (handler)The core handler implementation for get_market_stats, querying telekash_markets and aggregating results by category and source.
async function getMarketStats(supabase: SupabaseClient): Promise<ToolResult> { const { data: markets, error } = await supabase .from("telekash_markets") .select("id, status, category, source"); if (error) throw new Error(`Stats error: ${error.message}`); const all = markets || []; const byCategory: Record<string, number> = {}; const bySource: Record<string, number> = {}; for (const m of all) { byCategory[m.category || "other"] = (byCategory[m.category || "other"] || 0) + 1; bySource[m.source || "unknown"] = (bySource[m.source || "unknown"] || 0) + 1; - worker/src/tools.ts:179-180 (registration)The tool registration/dispatch logic within the main tool handler switch block.
case "get_market_stats": return getMarketStats(supabase); - worker/src/schema.ts:228-232 (schema)The MCP tool definition and schema for get_market_stats.
{ name: "get_market_stats", description: `Get aggregate statistics — total markets, categories, sources, and volume.`, inputSchema: { type: "object", properties: {}, required: [] }, },