Polymarket MCP server

Integrates with PolyMarket's API to fetch and analyze prediction market data for financial insights and decision support.
Back to servers
Setup instructions
Provider
berlinbra
Release date
Jan 17, 2025
Language
Python
Stats
28 stars

The PolyMarket MCP server provides access to prediction market data through a standardized interface. It allows you to retrieve real-time market information, prices, and historical data from PolyMarket's prediction markets, making it easy to integrate prediction market insights into your applications.

Installation Options

Installing via Smithery

The easiest way to install the PolyMarket MCP server for Claude Desktop is through Smithery:

npx -y @smithery/cli install polymarket_mcp --client claude

Manual Configuration for Claude Desktop

To configure the server manually for Claude Desktop, edit the configuration file:

  • MacOS: ~/Library/Application\ Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%/Claude/claude_desktop_config.json

Add the following to your configuration:

"mcpServers": {
    "polymarket-mcp": {
        "command": "uv",
        "args": [
        "--directory",
        "/Users/{INSERT_USER}/YOUR/PATH/TO/polymarket-mcp",
        "run",
        "polymarket-mcp"
        ],
        "env": {
            "KEY": "<insert poly market api key>",
            "FUNDER": "<insert polymarket wallet address>"
        }
    }
}

Installing Locally

  1. Clone the repository and install dependencies:
uv pip install -e .
  1. Create a .env file with your credentials:
Key=your_api_key_here
Funder=poly market wallet address

Running the Server

After installation, you can run the server directly:

uv run src/polymarket_mcp/server.py

If you want to run the server with the inspector:

npx @modelcontextprotocol/inspector uv --directory C:\\Users\\{INSERT_USER}\\YOUR\\PATH\\TO\\polymarket-mcp run src/polymarket_mcp/server.py

Available Tools

The PolyMarket MCP server provides four main tools for accessing prediction market data:

Get Market Information

Retrieves detailed information about a specific prediction market.

Input Schema:

{
    "market_id": {
        "type": "string",
        "description": "Market ID or slug"
    }
}

Example Response:

Title: Example Market
Category: Politics
Status: Open
Resolution Date: 2024-12-31
Volume: $1,234,567.89
Liquidity: $98,765.43
Description: This is an example prediction market...
---

List Markets

Lists available prediction markets with filtering options.

Input Schema:

{
    "status": {
        "type": "string",
        "description": "Filter by market status",
        "enum": ["open", "closed", "resolved"]
    },
    "limit": {
        "type": "integer",
        "description": "Number of markets to return",
        "default": 10,
        "minimum": 1,
        "maximum": 100
    },
    "offset": {
        "type": "integer",
        "description": "Number of markets to skip (for pagination)",
        "default": 0,
        "minimum": 0
    }
}

Example Response:

Available Markets:

ID: market-123
Title: US Presidential Election 2024
Status: Open
Volume: $1,234,567.89
---

ID: market-124
Title: Oscar Best Picture 2024
Status: Open
Volume: $234,567.89
---

Get Market Prices

Retrieves current prices and trading information for a market.

Input Schema:

{
    "market_id": {
        "type": "string",
        "description": "Market ID or slug"
    }
}

Example Response:

Current Market Prices for US Presidential Election 2024

Outcome: Democratic
Price: $0.6500
Probability: 65.0%
---

Outcome: Republican
Price: $0.3500
Probability: 35.0%
---

Get Market History

Retrieves historical price and volume data for a market.

Input Schema:

{
    "market_id": {
        "type": "string",
        "description": "Market ID or slug"
    },
    "timeframe": {
        "type": "string",
        "description": "Time period for historical data",
        "enum": ["1d", "7d", "30d", "all"],
        "default": "7d"
    }
}

Example Response:

Historical Data for US Presidential Election 2024
Time Period: 7d

Time: 2024-01-20T12:00:00Z
Price: $0.6500
Volume: $123,456.78
---

Time: 2024-01-19T12:00:00Z
Price: $0.6300
Volume: $98,765.43
---

Error Handling

The server includes comprehensive error handling for various scenarios:

  • Rate limiting (429 errors)
  • Invalid API keys (403 errors)
  • Invalid market IDs (404 errors)
  • Network connectivity issues
  • API timeout conditions (30-second timeout)
  • Malformed responses

All error messages are returned in a clear, human-readable format to help troubleshoot any issues.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "polymarket-mcp" '{"command":"uv","args":["run","src/polymarket_mcp/server.py"],"env":{"KEY":"<insert poly market api key>","FUNDER":"<insert polymarket wallet address>"}}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "polymarket-mcp": {
            "command": "uv",
            "args": [
                "run",
                "src/polymarket_mcp/server.py"
            ],
            "env": {
                "KEY": "<insert poly market api key>",
                "FUNDER": "<insert polymarket wallet address>"
            }
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "polymarket-mcp": {
            "command": "uv",
            "args": [
                "run",
                "src/polymarket_mcp/server.py"
            ],
            "env": {
                "KEY": "<insert poly market api key>",
                "FUNDER": "<insert polymarket wallet address>"
            }
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later