This skill is the shared data layer for the repository. It exists so that individual skills do not need to re-implement MCP session handling, query helpers, market metadata lookups, or local caching logic.
1. PredicTradar MCP Server https://api.predictradar.ai/api/mcp/v2 (primary)
2. polymarket-cli polymarket <command> (service degradation fallback)
3. Polymarket Data API https://data-api.polymarket.com (final fallback)
Use the PredicTradar MCP Server by default. It is the canonical shared entry point for this repo.
The live MCP service now requires a full MCP session handshake:
initializemcp-session-id response headernotifications/initializedtools/list and tools/callThe repository wrapper at mcp-client.js already handles this automatically, so skills should call the wrapper instead of implementing raw MCP requests unless they need low-level debugging.
Health endpoint observed on March 31, 2026:
service: predictradar-mcpversion: 1.0.0protocolVersion: 2025-03-26The current live tool catalog includes:
| Tool | Purpose | Notes |
|---|---|---|
| ------ | --------- | ------- |
get_traders | Trader list with sorting and pagination | Sort fields include volume_24h, volume_7d, volume_30d, pnl_24h, pnl_7d, pnl_30d, win_rate |
get_trader_detail | Detailed trader profile | Includes positions, recent activity, and analysis payloads |
get_markets | Market list | Supports status, search, limit, offset |
get_market_detail | Single-market detail | Newer high-level tool, useful when a skill already has a conditionId |
get_leaderboard | Ranked trader leaderboard | period: 24h, 7d, 30d, all |
get_market_stats | Aggregate market statistics | Includes volume, trader counts, active markets, hot markets |
search_events | Event search | Supports query, category, status, limit |
run_query_preview | Preferred read-only SQL preview | Preview mode only, limited rows |
run_query | Legacy alias for preview SQL | Keep compatibility, but prefer run_query_preview in new docs |
open_query_stream | Streamed SQL export | Use for larger result sets instead of overloading preview queries |
list_tables | Table catalog | Supports category filter: trading, market, user, system, all |
describe_table | Table schema inspection | Can include sample rows |
Key documentation updates compared with the older version:
get_market_detail should be listed as a first-class tool.run_query_preview should be treated as the preferred preview-query tool.run_query should be described as a compatibility alias.open_query_stream should be documented for larger exports.Live list_tables currently returns two trading tables:
| Table | Description | Approx. Rows |
|---|---|---|
| ------ | ------------- | -------------- |
trades | Historical trade records including trade, mint, burn, and redeem actions | ~296.6M |
positions | Current and historical positions | ~30.5M |
These row counts are service-side approximations and may grow over time.
tradesImportant columns currently exposed by describe_table("trades"):
idcreated_atupdated_atplatformwallet_addressplatform_idtx_hashtransaction_hashcondition_idtrader_idmarket_idtoken_idsidetypeoutcomeoutcome_sidepricesizeamountfeefee_amountoutcome_indexprofitusd_amountchain_idblock_numberblock_timestamptraded_atPractical takeaways:
amount remains the most portable trade-size field for aggregate SQL.usd_amount is available and nullable, which is useful for whale-style filters.type is not just trade; it also includes mint, burn, and redeem.condition_id and market_id are both available directly in the table, so legacy mapping tables should not be required for normal skill flows.positionsImportant columns currently exposed by describe_table("positions"):
idcreated_atupdated_atplatformwallet_addresstrader_idmarket_idtoken_idcondition_idoutcomeoutcome_indexoutcome_sidesizesize_frozenavg_priceavg_entry_pricecurrent_priceinitial_valuecurrent_valuetotal_boughtrealized_pnlunrealized_pnlunrealized_pnl_percentdaily_pnl_changeis_redeemableis_closedchain_idlast_updated_atopened_atclosed_atPractical takeaways:
avg_entry_price, current_price, is_redeemable, and lifecycle timestamps should now be reflected in any field documentation.positions is richer than the older docs implied, so skills can describe both PnL state and lifecycle state more precisely.const mcp = require("../../polymarket-data-layer/scripts/mcp-client");
// health + handshake
const ok = await mcp.ping();
const health = await mcp.health();
const init = await mcp.initialize();
// high-level tools
const leaderboard = await mcp.getLeaderboard({ period: "7d", rankBy: "pnl", limit: 10 });
const traders = await mcp.getTraders({ sortBy: "pnl_7d", order: "desc", limit: 20 });
const markets = await mcp.getMarkets({ status: "active", search: "Fed", limit: 20 });
const market = await mcp.getMarketDetail("0x...");
// preview query
const rows = await mcp.query(`
SELECT condition_id, SUM(amount) AS volume_24h
FROM trades
WHERE traded_at >= now() - INTERVAL 1 DAY
AND type = 'trade'
GROUP BY condition_id
ORDER BY volume_24h DESC
LIMIT 20
`);
// streamed query export
const stream = await mcp.openQueryStream(`
SELECT wallet_address, SUM(amount) AS volume_30d
FROM trades
WHERE traded_at >= now() - INTERVAL 30 DAY
GROUP BY wallet_address
`);
MCP_URL=https://api.predictradar.ai
MCP_API_KEY=pr_public_predictradar
The wrapper already defaults to these values unless overridden.
Use this for:
Highlights:
openQueryStream, consumeQueryStream, cancelQueryStream, and queryStreamgetTraders, getTraderDetail, getLeaderboard, getMarketStats, getMarkets, getMarketDetail, and searchEventsRun this when you need to inspect:
Use this when a skill needs:
conditionIdUse this for reusable repo-level aggregations such as:
Use this only when a skill explicitly needs the local smart-money classification layer. Prefer read-only cache access when possible unless the workflow truly requires a fresh classification.
Use this for local file-backed cache reads and writes inside longer-running scripts.
Use preview SQL when:
Guidance:
mcp.query(...) or mcp.queryWithRetry(...)LIMITtype = 'trade' when you do not want mint, burn, or redeemUse open_query_stream when:
If MCP is unavailable:
polymarket-cli when appropriateRecommended cache behavior:
condition_id is the canonical cross-system market key.wallet_address should be normalized to lowercase for SQL comparisons.run_query is no longer the best term for new docs; describe it as a legacy alias and prefer run_query_preview.open_query_stream should be mentioned anywhere a skill may need larger result sets.mcp-client.js.共 1 个版本