polymarket-mcp
Enables AI agents to discover and analyze prediction markets, execute trades, and manage positions on Polymarket via the Model Context Protocol.
README
📊 Polymarket MCP Server
📖 Overview
The Polymarket MCP Server enables AI agents to interact with Polymarket, a leading prediction market platform on Polygon. This server provides comprehensive access to market data, real-time pricing, order books, and trading capabilities through the Polymarket API.
By implementing the Model Context Protocol (MCP), this server allows Large Language Models (LLMs) to discover prediction markets, analyze odds (probabilities), execute trades, and track portfolio positions directly through their context window, bridging the gap between AI and decentralized prediction markets.
✨ Features
- Market Discovery: Search and filter prediction markets by keywords, tags, and status.
- Real-time Pricing: Access live price data, implied probabilities, and depth-of-market (order books) for any outcome token.
- Trading Capabilities: Place limit orders, market orders, and manage open orders (requires private key).
- Portfolio Tracking: Monitor user positions, trade history, and balances for specific wallet addresses.
- Order Management: View, cancel, and manage open orders across all markets.
📦 Installation
🚀 Using npx (Recommended)
To use this server without installing it globally:
npx @iqai/mcp-polymarket
🔧 Build from Source
git clone https://github.com/IQAIcom/mcp-polymarket.git
cd mcp-polymarket
pnpm install
pnpm run build
⚡ Running with an MCP Client
Add the following configuration to your MCP client settings (e.g., claude_desktop_config.json).
📋 Minimal Configuration (Read-Only)
{
"mcpServers": {
"polymarket": {
"command": "npx",
"args": ["-y", "@iqai/mcp-polymarket"]
}
}
}
⚙️ Advanced Configuration (With Trading)
{
"mcpServers": {
"polymarket": {
"command": "npx",
"args": ["-y", "@iqai/mcp-polymarket"],
"env": {
"POLYMARKET_PRIVATE_KEY": "your_private_key_here",
"POLYGON_RPC_URL": "https://polygon-mainnet.g.alchemy.com/v2/<YOUR_KEY>"
}
}
}
}
🔐 Configuration (Environment Variables)
| Variable | Required | Description | Default |
|---|---|---|---|
POLYMARKET_PRIVATE_KEY |
No | Private key for trading (enables trading tools) | - |
POLYGON_RPC_URL |
No | Polygon RPC URL for transactions | https://polygon-rpc.com |
CLOB_API_BASE |
No | Polymarket CLOB API base URL | https://clob.polymarket.com |
CHAIN_ID |
No | Blockchain network chain ID | 137 (Polygon) |
SIGNATURE_TYPE |
No | Signature type for signing transactions | 2 |
POLYMARKET_FUNDER |
No | Funder address for transactions | - |
FUNDER_ADDRESS |
No | Alternative funder address (alias) | - |
💡 Usage Examples
🔍 Market Discovery
- "What are the most active prediction markets on Polymarket right now?"
- "Search for markets related to 'Bitcoin' or 'BTC'."
- "Find markets in the 'Crypto' category."
- "What events are trending on Polymarket today?"
📊 Analytics & Pricing
- "Show me the order book for the 2024 election market."
- "What is the current probability implied by the price of the 'Yes' token?"
- "Get detailed information about the 'will-trump-win-2024' market."
💼 Portfolio & Trading (Requires Private Key)
- "What's my current USDC balance and allowance?"
- "Show me all my open orders across all markets."
- "Place a buy order for 100 shares at 0.65 price."
- "Cancel all my open orders on this market."
🛠️ MCP Tools
<!-- AUTO-GENERATED TOOLS START -->
approve_allowances
Grant the USDC and Conditional Tokens approvals required to trade on Polymarket. Automatically approves only the contracts that don't already have approvals set. Includes both regular and NegRisk markets. These approvals are standard ERC20/ERC1155 approvals, revocable at any time in your wallet.
| Parameter | Type | Required | Description |
|---|---|---|---|
waitForConfirmations |
integer | false | How many confirmations to wait before returning (0 = return immediately after broadcasting). Default: 0 |
cancel_all_orders
Cancel all open orders for the authenticated account.
No parameters
cancel_order
Cancel a specific order by its ID.
| Parameter | Type | Required | Description |
|---|---|---|---|
orderId |
string | true | The unique identifier of the order to cancel |
get_all_tags
Get a list of all available tags for categorizing markets.
No parameters
get_balance_allowance
Get balance and allowance information for the authenticated account. Can check COLLATERAL or CONDITIONAL tokens.
| Parameter | Type | Required | Description |
|---|---|---|---|
assetType |
string | true | Asset type to check balance for: COLLATERAL or CONDITIONAL |
tokenID |
string | false | Optional token ID for conditional token balance |
get_event_by_slug
Get detailed information about a specific event by its slug identifier. Events group multiple related markets.
| Parameter | Type | Required | Description |
|---|---|---|---|
slug |
string | true | The event slug identifier |
get_market_by_slug
Get detailed information about a specific market by its slug identifier. The slug can be extracted from the Polymarket URL.
| Parameter | Type | Required | Description |
|---|---|---|---|
slug |
string | true | The market slug identifier (e.g., 'will-trump-win-2024') |
get_markets_by_tag
Get markets filtered by a specific tag ID. Useful for finding markets in specific categories.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
tag_id |
string | true | The tag ID to filter by | |
limit |
number | false | 20 | Number of markets to return (default: 20) |
closed |
boolean | false | false | Include closed markets (default: false) |
get_open_orders
Get all open orders for the authenticated account. Can optionally filter by market.
| Parameter | Type | Required | Description |
|---|---|---|---|
market |
string | false | Optional market address to filter orders by |
get_order
Get details of a specific order by its ID.
| Parameter | Type | Required | Description |
|---|---|---|---|
orderId |
string | true | The unique identifier of the order |
get_order_book
Get the current order book for a specific market token. Shows all active buy and sell orders.
| Parameter | Type | Required | Description |
|---|---|---|---|
token_id |
string | true | The token ID for the market outcome |
get_positions
Get all positions for a wallet address with current values. Returns position details including size, current price, current value, and P&L. Uses the Polymarket Data API for accurate position valuation.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
user |
string | false | Wallet address to fetch positions for. If not provided, uses POLYMARKET_FUNDER env var. | |
limit |
number | false | 100 | Maximum number of positions to return (default: 100) |
get_trade_history
Get trade history for the authenticated account. Can optionally filter by market or maker address.
| Parameter | Type | Required | Description |
|---|---|---|---|
market |
string | false | Optional market address to filter trades by |
maker_address |
string | false | Optional maker address to filter trades by |
list_active_markets
List all currently active markets with pagination. Returns markets that are not yet closed.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
limit |
number | false | 20 | Number of markets to return (default: 20, max: 100) |
offset |
number | false | 0 | Number of markets to skip for pagination (default: 0) |
place_market_order
Place a market order that executes immediately at current market price. IMPORTANT: For BUY orders, amount is the dollar amount ($USD) you want to spend. For SELL orders, amount is the number of shares to sell. Example: amount=5, side=BUY means 'spend $5 to buy shares at market price'. Minimum $1 for BUY orders.
| Parameter | Type | Required | Description |
|---|---|---|---|
tokenId |
string | true | The token ID of the market outcome to trade |
amount |
number | true | BUY orders: Dollar amount ($) to spend. SELL orders: Number of shares to sell. Minimum $1 for BUY orders. |
side |
string | true | The side of the order: BUY or SELL |
orderType |
string | false | Order type: FOK (Fill or Kill) or FAK (Fill and Kill). Default: FOK |
place_order
Place a limit order on Polymarket at a specific price. Specify the number of shares (size) and price (0-1). For both BUY and SELL, you specify the number of shares you want to trade. Example: size=10, price=0.6 means buy/sell 10 shares at $0.60 per share (total: $6).
| Parameter | Type | Required | Description |
|---|---|---|---|
tokenId |
string | true | The token ID of the market outcome to trade |
price |
number | true | The limit price for the order (between 0 and 1). This is the probability/price per share. |
size |
number | true | Number of shares to trade. For both BUY and SELL orders, this is always the number of outcome tokens/shares. |
side |
string | true | The side of the order: BUY or SELL |
orderType |
string | false | Order type: GTC (Good Till Cancelled) or GTD (Good Till Date). Default: GTC |
redeem_positions
Redeem (claim) winnings from a resolved Polymarket prediction market. Use this to collect USDC from positions in markets that have been settled. For regular markets, you need the conditionId. For negative risk markets, you also need the tokenId and should set negRisk=true. The market must be resolved before redemption is possible.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
conditionId |
string | true | The condition ID (market ID) for the resolved market. This is typically a 32-byte hex string. | |
tokenId |
string | false | The token ID of the position to redeem. Required for negRisk markets, optional for regular markets. | |
outcomeIndex |
number | false | The outcome index: 0 for Yes/first outcome, 1 for No/second outcome. Used for negRisk markets to determine which tokens to redeem. | |
negRisk |
boolean | false | false | Whether this is a negative risk market. Negative risk markets use the NegRiskAdapter contract for redemption. Default: false |
search_markets
Search for markets, events, and profiles using text search.
| Parameter | Type | Required | Description |
|---|---|---|---|
query |
string | true | Search query text |
update_balance_allowance
Update balance and allowance for the authenticated account. Required before trading.
| Parameter | Type | Required | Description |
|---|---|---|---|
assetType |
string | true | Asset type to update allowance for: COLLATERAL or CONDITIONAL |
tokenID |
string | false | Optional token ID for conditional token |
<!-- AUTO-GENERATED TOOLS END -->
👨💻 Development
🏗️ Build Project
pnpm run build
👁️ Development Mode (Watch)
pnpm run watch
✅ Linting & Formatting
pnpm run lint
pnpm run format
📁 Project Structure
src/tools/: Individual tool definitionssrc/services/: API client and business logicsrc/index.ts: Server entry point
📚 Resources
⚠️ Disclaimer
This project is an unofficial tool and is not directly affiliated with Polymarket. It interacts with financial and prediction market data. Users should exercise caution and verify all data independently. Trading in prediction markets involves risk.
📄 License
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。