Polymarket MCP Server

Polymarket MCP Server

Enables AI assistants to discover prediction markets, view real-time data, execute trades (market/limit orders), and manage portfolios on Polymarket.

Category
访问服务器

README

Polymarket MCP Server

A Model Context Protocol (MCP) server that provides AI assistants with the ability to interact with Polymarket.

Features

  • Market Discovery: Browse and search current prediction markets
  • Real-time Data: Get detailed market information, prices, and statistics
  • Trading: Place market orders (FOK/FAK) and limit orders (GTC/GTD)
  • Portfolio Management: View balances, positions, and P&L
  • Order Management: Track and manage your active orders
  • Multi-format Support: Works with market slugs or direct token IDs

Installation

1. Clone and Install

git clone https://github.com/yourusername/polymarket-mcp-server.git
cd <folder-name>
pnpm install

2. Install Required Dependencies

pnpm install @modelcontextprotocol/sdk zod @polymarket/clob-client ethers

3. Environment Configuration

Create a .env file in the project root:

# Required: Your Polygon wallet private key
PRIVATE_KEY=your_private_key_here

# Optional: Custom CLOB API URL (defaults to https://clob.polymarket.com)
CLOB_API_URL=https://clob.polymarket.com

# Optional: Signature type (defaults to 0)
SIGNATURE_TYPE=0

# Optional: Existing API credentials (will be auto-generated if not provided)
CLOB_API_KEY=your_api_key
CLOB_SECRET=your_secret
CLOB_PASS_PHRASE=your_passphrase

4. MCP Configuration

Add the server to your MCP settings file:


{
  "mcpServers": {
    "poly": {
      "command": "npx",
      "args": ["polymarket-mcp"],
      "env": {
        "PRIVATE_KEY": ""
      }
    }
  }
}

Available Tools

1. Market Discovery

getAllMarkets

Get current prediction markets with optional filtering.

Get me today's trending markets

getMarketDetails

Get detailed information about a specific market using its slug.

Get details for the market "will-donald-trump-win-the-2024-us-presidential-election"
Show me info about "bitcoin-above-100k-by-end-of-2024"

2. Trading Operations

placeMarketOrder

Execute immediate market orders (Fill or Kill / Fill and Kill).

Buy $100 of YES on "bitcoin-above-100k-by-end-of-2024" using FOK order
Sell $50 of NO on the Trump election market with FAK

Parameters:

  • marketSlug or tokenID: Market identifier
  • outcome: YES or NO (if using marketSlug)
  • amount: USD amount to trade
  • side: BUY or SELL
  • orderType: FOK (Fill or Kill) or FAK (Fill and Kill)

placeLimitOrder

Place limit orders at specific prices (Good Till Cancelled / Good Till Date).

Place a limit buy order for 100 shares at $0.65 on the Bitcoin market
Set a GTC sell order for 50 shares at $0.80 on Trump election

Parameters:

  • marketSlug or tokenID: Market identifier
  • outcome: YES or NO (if using marketSlug)
  • price: Price per share (0-1)
  • size: Number of shares
  • side: BUY or SELL
  • orderType: GTC (Good Till Cancelled) or GTD (Good Till Date)
  • expirationMinutes: Expiration time (GTD only)

3. Portfolio Management

getPortfolio

View complete portfolio including balances and positions.

Show me my portfolio
What's my current P&L?
Check my USDC balance

getOrder

Get details of a specific order by ID.

Check order status for 0x831680cb77da95792af5a052c87c8abf9d2ae5cb21f275670bc0ff58f2823c5c

Usage Examples

Starting the Server

Important: Always run the server using Node.js directly to ensure proper initialization:

node <path-to-index.js>

This will:

Initialize your wallet connection Set up required token allowances (USDC approvals for CTF and Exchange contracts) Generate or use existing API credentials Start the MCP server

Basic Market Research

"Get details about the market 'ai-will-achieve-agi-by-2025'"

Simple Trading

"Buy $20 of YES on 'will-spacex-reach-mars-by-2030' using a market order"

Portfolio Monitoring

"Show me my current portfolio and P&L"

"Check my USDC balance on Polymarket"

Advanced Trading

"Set a GTC limit sell order for 100 shares at $0.85 on token ID 123456"

"Place a FOK buy order for $500 on the climate change market"

"Check the status of my order 0x831680..."

Market Slug Examples

Market slugs are found in Polymarket URLs:

  • https://polymarket.com/event/will-donald-trump-win-the-2024-us-presidential-election

    • Slug: will-donald-trump-win-the-2024-us-presidential-election
  • https://polymarket.com/event/bitcoin-above-100k-by-end-of-2024

    • Slug: bitcoin-above-100k-by-end-of-2024

API Limits

  • Polymarket may have rate limits on API calls
  • Large orders may have slippage on smaller markets
  • Some markets may have low liquidity

Troubleshooting

Common Issues

"Client not initialized"

  • Check your PRIVATE_KEY is set correctly
  • Ensure you have USDC balance for gas fees
  • Verify Polygon network connectivity

"Market not found"

  • Double-check the market slug spelling
  • Ensure the market is still active
  • Try using direct token ID instead

"Insufficient balance"

  • Add USDC to your Polygon wallet
  • Check if allowances were set properly
  • Verify you're on Polygon Mainnet

"Order failed"

  • Check if market is still open for trading
  • Verify price is within valid range (0-1)
  • Ensure sufficient balance for the trade

API Reference

Market Data Endpoints

  • Gamma API: https://gamma-api.polymarket.com/markets
  • Data API: https://data-api.polymarket.com/positions
  • CLOB API: https://clob.polymarket.com

Contract Addresses (Polygon)

  • USDC: 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174
  • CTF: 0x4D97DCd97eC945f40cF65F87097ACe5EA0476045
  • Exchange: 0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Support

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选