mcpField
P
PolyMarket MCP Server

PolyMarket MCP Server

本地服务
github.com/berlinbra金融数据14473 周前更新

关于 PolyMarket MCP Server

PolyMarket MCP Server 是一个通过 PolyMarket API 访问预测市场数据的 MCP 服务,提供市场信息、价格与历史数据。适合需要在 AI 客户端中查询预测市场状态的用户。

主要功能

  1. 01实时价格与概率数据
  2. 02市场详情,包括分类与结算日期
  3. 03历史价格与成交量,支持 1d、7d、30d、all
  4. 04内置错误处理与速率限制管理

适用场景

  1. 01查询某个预测市场的当前价格与概率
  2. 02按状态筛选并列出可用市场
  3. 03分析某一市场在指定时间段内的价格走势

MCP 相关

该项目是 MCP 服务,向 MCP 客户端暴露 get-market-info、list-markets、get-market-prices 与 get-market-history 四个工具。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"polymarket": {
"command": "npx",
"args": [
"-y",
"@smithery/cli"
]
}
}
}
启动命令npx -y @smithery/cli

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npm@smithery/cli

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

PolyMarket MCP 服务

smithery badge

一个模型上下文协议(MCP)服务,可通过 PolyMarket API 访问预测市场数据。此服务实现了标准化接口,用于获取预测市场的市场信息、价格和历史数据。

PolyMarket 服务器 MCP 服务

MseeP.ai Security Assessment Badge

功能

  • 实时预测市场数据,包含当前价格和概率
  • 详细的市场信息,包括类别、结算日期和描述
  • 历史价格和交易量数据,支持自定义时间范围(1d、7d、30d、all)
  • 内置错误处理和速率限制管理
  • 数据格式简洁,便于使用

安装

通过 Smithery 安装

若要通过 Smithery 自动为 Claude Desktop 安装 PolyMarket Predictions:

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

贡献

欢迎贡献!欢迎提交 Pull Request。对于重大更改,请先提出 issue,讨论你希望进行的更改。

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。