Graph Polymarket MCP
Query Polymarket prediction market data via The Graph subgraphs and Polymarket REST APIs (Gamma + CLOB) — market search, live prices, order books, trader P&L, positions, open interest, resolution status, and trader profiles.
Tools
Polymarket REST API (no API key needed)
- - searchmarkets — Search markets by text query with filters (active, closed, sort by volume/liquidity)
- getmarketinfo — Get detailed market metadata by slug or condition ID
- listpolymarketevents — Browse events (groups of related markets) with tag/status filters
- getpolymarketevent — Get a single event with all its associated markets
- getliveprices — Real-time CLOB prices for outcome tokens (buy/sell, single or batch)
- getlivespread — Bid-ask spread + midpoint for assessing market liquidity
- getliveorderbook — Full order book (all resting bids and asks) for a token
- getpricehistory — Historical price time-series (1m to max interval, configurable fidelity)
- getlasttrade — Last trade price for an outcome token
- getclobmarket — CLOB market details: token IDs, live prices, min order/tick sizes
- searchmarkets_enriched — Power tool: search + auto-enrich with live CLOB prices AND on-chain resolution status
The Graph Subgraphs (requires GRAPHAPIKEY)
- - listsubgraphs — List all available Polymarket subgraphs with descriptions and key entities
- getsubgraphschema — Get the full GraphQL schema for a specific subgraph
- querysubgraph — Execute a custom GraphQL query against any subgraph
- getmarketdata — Get market/condition data with outcomes and resolution status
- getglobalstats — Platform stats: market counts, volume, fees, trades
- getaccountpnl — Trader P&L and performance metrics (winRate, profitFactor, maxDrawdown)
- gettoptraders — Leaderboard ranked by PnL, winRate, volume, or profitFactor
- getdailystats — Daily volume, fees, trader counts, and market activity
- getmarketpositions — Top holders for a specific outcome token with their P&L
- getuserpositions — A user's current token positions
- getrecentactivity — Recent splits, merges, and redemptions
- getorderbooktrades — Recent order fills with maker/taker filtering
- getmarketopeninterest — Top markets ranked by USDC locked in positions
- getoihistory — Hourly OI snapshots for a specific market
- getglobalopeninterest — Total platform-wide open interest and market count
- getmarketresolution — UMA oracle resolution status with filtering
- getdisputedmarkets — Markets disputed during oracle resolution
- getmarketrevisions — Moderator interventions and updates on market resolution
- gettraderprofile — Full trader profile: first seen, CTF events, USDC flows
- gettraderusdc_flows — USDC deposit/withdrawal history with direction filtering
Requirements
- - Runtime: Node.js >= 18 (runs via
npx) - Environment variables:
-
GRAPH_API_KEY (required for subgraph tools) — Free API key from
The Graph Studio. Free tier: 100K queries/month.
- REST API tools (search, prices, order books) work without any API key.
Install
CODEBLOCK0
Network & Data Behavior
- - Subgraph tools make GraphQL requests to The Graph Gateway (
gateway.thegraph.com) using your API key. - REST API tools query Polymarket's public endpoints (
gamma-api.polymarket.com and clob.polymarket.com) directly — no authentication needed. - Eight subgraphs are queried: Main, Beefy P&L, Slimmed P&L, Activity, Orderbook, Open Interest, Resolution, and Traders.
- No local database or persistent storage is used.
- The SSE transport (
--http / --http-only) starts a local HTTP server on port 3851 (configurable via MCP_HTTP_PORT env var).
Use Cases
- - Search and discover prediction markets by topic, category, or keyword
- Get real-time prices, order books, and spreads for any market
- Analyze price history and market trends
- Get platform-wide stats, volume, and market rankings
- Analyze trader P&L, performance metrics, and leaderboards
- Track open interest trends and market positions
- Monitor market resolution lifecycle and disputed markets
- Run custom GraphQL queries against 8 specialized Polymarket subgraphs
Graph Polymarket MCP
通过 The Graph 子图和 Polymarket REST API(Gamma + CLOB)查询 Polymarket 预测市场数据——市场搜索、实时价格、订单簿、交易者盈亏、持仓、未平仓合约、解析状态以及交易者档案。
工具
Polymarket REST API(无需 API 密钥)
- - searchmarkets — 通过文本查询搜索市场,支持筛选条件(活跃、已关闭、按交易量/流动性排序)
- getmarketinfo — 通过 slug 或条件 ID 获取详细市场元数据
- listpolymarketevents — 浏览事件(相关市场组),支持标签/状态筛选
- getpolymarketevent — 获取单个事件及其所有关联市场
- getliveprices — 结果代币的实时 CLOB 价格(买入/卖出,单次或批量)
- getlivespread — 买卖价差 + 中点价,用于评估市场流动性
- getliveorderbook — 完整订单簿(所有挂单的买盘和卖盘)
- getpricehistory — 历史价格时间序列(1分钟至最大间隔,可配置精度)
- getlasttrade — 结果代币的最新成交价
- getclobmarket — CLOB 市场详情:代币 ID、实时价格、最小订单/跳动单位
- searchmarkets_enriched — 高级工具:搜索 + 自动补充实时 CLOB 价格和链上解析状态
The Graph 子图(需要 GRAPHAPIKEY)
- - listsubgraphs — 列出所有可用的 Polymarket 子图及其描述和关键实体
- getsubgraphschema — 获取特定子图的完整 GraphQL 模式
- querysubgraph — 对任意子图执行自定义 GraphQL 查询
- getmarketdata — 获取市场/条件数据,包含结果和解析状态
- getglobalstats — 平台统计:市场数量、交易量、费用、交易次数
- getaccountpnl — 交易者盈亏和绩效指标(胜率、利润因子、最大回撤)
- gettoptraders — 按盈亏、胜率、交易量或利润因子排名的排行榜
- getdailystats — 每日交易量、费用、交易者数量和市场活动
- getmarketpositions — 特定结果代币的持仓大户及其盈亏
- getuserpositions — 用户的当前代币持仓
- getrecentactivity — 近期拆分、合并和赎回操作
- getorderbooktrades — 近期订单成交,支持做市商/吃单者筛选
- getmarketopeninterest — 按锁定 USDC 持仓量排名的热门市场
- getoihistory — 特定市场的每小时未平仓合约快照
- getglobalopeninterest — 全平台总未平仓合约和市场数量
- getmarketresolution — UMA 预言机解析状态,支持筛选
- getdisputedmarkets — 预言机解析期间存在争议的市场
- getmarketrevisions — 管理员干预和市场解析更新记录
- gettraderprofile — 完整交易者档案:首次出现时间、CTF 事件、USDC 资金流
- gettraderusdc_flows — USDC 充值/提现历史,支持方向筛选
要求
- - 运行环境: Node.js >= 18(通过 npx 运行)
- 环境变量:
- GRAPH
APIKEY(子图工具必需)— 从
The Graph Studio 获取免费 API 密钥。免费套餐:每月 10 万次查询。
- REST API 工具(搜索、价格、订单簿)无需任何 API 密钥即可使用。
安装
bash
GRAPHAPIKEY=your-key npx graph-polymarket-mcp
网络与数据行为
- - 子图工具使用您的 API 密钥向 The Graph 网关(gateway.thegraph.com)发送 GraphQL 请求。
- REST API 工具直接查询 Polymarket 的公共端点(gamma-api.polymarket.com 和 clob.polymarket.com)——无需认证。
- 查询八个子图:主网、增强盈亏、精简盈亏、活动、订单簿、未平仓合约、解析和交易者。
- 不使用本地数据库或持久化存储。
- SSE 传输(--http / --http-only)在端口 3851 上启动本地 HTTP 服务器(可通过 MCPHTTPPORT 环境变量配置)。
使用场景
- - 按主题、类别或关键词搜索和发现预测市场
- 获取任何市场的实时价格、订单簿和价差
- 分析价格历史和市场趋势
- 获取平台范围的统计数据、交易量和市场排名
- 分析交易者盈亏、绩效指标和排行榜
- 跟踪未平仓合约趋势和市场持仓
- 监控市场解析生命周期和争议市场
- 针对 8 个专门的 Polymarket 子图运行自定义 GraphQL 查询