P

PolyMarket接口

@berlinbra/polymarket-mcp
1 Stars 457 次浏览 berlinbra 更新于 2026-08-23

启用与PolyMarket API的交互,以获取预测市场数据,例如市场信息、价格和历史数据,并具有强大的错误处理和速率限制管理功能。

该服务暂未提供标准配置,请参考 README 手动接入

可用工具 (4 个)

该服务在 MCP 协议中暴露的工具,AI 可按需调用

get-market-info 1 个参数 需填 1 项

Get detailed information about a specific prediction market

必填参数:market_id

list-markets 3 个参数

Get a list of prediction markets with optional filters

该工具无需必填参数,直接调用即可

get-market-prices 1 个参数 需填 1 项

Get current prices and trading information for a market

必填参数:market_id

get-market-history 2 个参数 需填 1 项

Get historical price and volume data for a market

必填参数:market_id

服务介绍

PolyMarket MCP 服务器

smithery 徽章

这是一个通过 PolyMarket API 提供预测市场数据访问的 Model Context Protocol (MCP) 服务器。该服务器实现了一个标准化接口,用于从预测市场检索市场信息、价格和历史数据。

功能

  • 实时预测市场数据,包括当前价格和概率
  • 详细的市场信息,包括类别、结算日期和描述
  • 可自定义时间范围的历史价格和成交量数据(1天、7天、30天、全部)
  • 内置错误处理和速率限制管理
  • 清晰的数据格式以便于使用

安装

通过 Smithery 安装

要通过 Smithery 自动安装适用于 Claude Desktop 的 PolyMarket 预测:

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

Claude Desktop

  • 在 MacOS 上: ~/Library/Application\ Support/Claude/claude_desktop_config.json
  • 在 Windows 上: %APPDATA%/Claude/claude_desktop_config.json
    "mcpServers": {
        "polymarket-mcp": {
            "command": "uv",
            "args": [
            "--directory",
            "/Users/{INSERT_USER}/YOUR/PATH/TO/polymarket-mcp",
            "run",
            "polymarket-mcp" //or src/polymarket_mcp/server.py
            ],
            "env": {
                "KEY": "<insert poly market api key>",
                "FUNDER": "<insert polymarket wallet address"
            }
        }
    }

本地运行

  1. 克隆仓库并安装依赖项:

安装库

uv pip install -e .

运行

在通过 JSON 文件将 Claude 客户端与 MCP 工具连接并安装包后,Claude 应能看到服务器的 mcp 工具:

你可以自己运行服务器:
在 polymarket-mcp 仓库中:

uv run src/polymarket_mcp/server.py

*如果你想同时运行服务器检查器和服务器:

npx @modelcontextprotocol/inspector uv --directory C:\\Users\\{INSERT_USER}\\YOUR\\PATH\\TO\\polymarket-mcp run src/polymarket_mcp/server.py
  1. 创建一个包含你的 PolyMarket API 密钥的 .env 文件:
Key=your_api_key_here
Funder=poly market wallet address

在通过 JSON 文件将 Claude 客户端与 MCP 工具连接后,运行服务器:
在 alpha-vantage-mcp 仓库中: uv run src/polymarket_mcp/server.py

可用工具

服务器实现了四个工具:

  • get-market-info: 获取特定预测市场的详细信息
  • list-markets: 列出可用的预测市场,并提供过滤选项
  • get-market-prices: 获取当前价格和交易信息
  • get-market-history: 获取历史价格和成交量数据

get-market-info

输入模式:

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

示例响应:

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

输入模式:

{
    "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
    }
}

示例响应:

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

输入模式:

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

示例响应:

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

输入模式:

{
    "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"
    }
}

示例响应:

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
---

错误处理

服务器包括针对各种情况的全面错误处理:

  • 速率限制(429 错误)
  • 无效的 API 密钥(403 错误)
  • 无效的市场 ID(404 错误)
  • 网络连接问题
  • API 超时条件(30 秒超时)
  • 格式错误的响应

错误消息以清晰的人类可读格式返回。

前提条件

  • Python 3.9 或更高版本
  • httpx>=0.24.0
  • mcp-core
  • python-dotenv>=1.0.0

贡献

请注意,上述翻译保持了原文档的 Markdown 格式不变,代码块和链接内容也原样保留。

欢迎贡献!请随时提交 Pull Request。对于重大更改,请先打开一个 issue 来讨论你想要更改的内容。

相关 MCP 服务