Skip to main content
Glama
joinQuantish

Polymarket MCP Server

by joinQuantish

Polymarket MCP Server

⚠️ 注意:Quantish 正在逐步关闭。 Quantish 平台(quantish.live)即将停止运营。该 MCP 服务器是自托管的,仍可独立运行,但 Quantish 团队将不再维护或更新此项目。如果你正在预测市场领域进行开发,并且需要实时数据基础设施,可以看看 polynode.dev

用于在 Polymarket 预测市场进行交易的自托管 MCP 服务器。

概述

该包提供了一个 MCP(模型上下文协议)服务器,使 AI 智能体能够通过 Polygon 网络在 Polymarket 预测市场进行交易。

Related MCP server: polymarket-mcp

功能

  • 完整 Polymarket 交易 - 在任何 Polymarket 市场上买入/卖出

  • Polygon 钱包管理 - 通过 Safe 集成生成和管理钱包

  • 无 Gas 交易 - 大多数操作使用 Polymarket 的中继器(无需 MATIC)

  • MCP 兼容 - 可与 Claude、Cursor 以及任何 MCP 客户端配合使用

  • 可自托管 - 可在 Railway、Fly.io 或任何 Node.js 主机上运行

快速开始

git clone https://github.com/joinQuantish/polymarket-mcp
cd polymarket-mcp
npm install

环境变量

变量

必需

描述

DATABASE_URL

PostgreSQL 连接字符串

ENCRYPTION_KEY

用于钱包加密的 32 字节十六进制字符串

POLYGON_RPC_URL

Polygon RPC 端点

BOT_SIGNING_SECRET

用于受信任机器人 HMAC 身份验证的密钥

PORT

服务器端口(默认为 3000)

生成加密密钥

# Generate ENCRYPTION_KEY (32 bytes = 64 hex chars)
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"

# Generate BOT_SIGNING_SECRET (for trusted bot auth)
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"

数据库设置

任何 PostgreSQL 数据库都可以使用。可选方案:

提供方

备注

Railway

添加 PostgreSQL 服务,从变量中复制 DATABASE_URL

Supabase

supabase.com 提供免费套餐,从 Settings > Database 复制连接字符串

Neon

neon.tech 提供无服务器 Postgres,有免费套餐

本地 Docker

docker run -e POSTGRES_PASSWORD=pass -p 5432:5432 postgres

设置好 DATABASE_URL 后运行:

# Generate Prisma client
npm run db:generate

# Create tables
npm run db:push

运行服务器

# Development
npm run dev

# Production
npm run build
npm start

可用工具

账户与钱包

工具

描述

request_api_key

使用新钱包创建账户(或恢复现有账户)

setup_wallet

部署 Safe 钱包并设置授权

get_wallet_status

检查钱包部署和授权状态

get_balances

获取 USDC/MATIC 余额

get_deposit_addresses

获取存款地址(EVM、Solana、BTC)

export_private_key

导出钱包私钥

import_private_key

导入现有钱包

交易

工具

描述

place_order

下买单或卖单

cancel_order

取消挂单

cancel_all_orders

取消所有挂单

get_orders

获取订单历史

execute_atomic_orders

以原子方式执行多个订单

get_orderbook

获取市场买盘/卖盘

get_price

获取市场中间价

持仓

工具

描述

get_positions

获取你的持仓

sync_positions

从 Polymarket API 同步持仓

get_claimable_winnings

检查可领取的奖金

claim_winnings

领取已结算市场的奖金

get_onchain_shares

获取所有 ERC-1155 持仓(包括赠送的)

转账与兑换

工具

描述

transfer_usdc

发送桥接 USDC

transfer_native_usdc

发送 Circle 原生 USDC

transfer_shares

发送 ERC-1155 份额

send_matic

从 EOA 发送 MATIC

swap_tokens

通过 LI.FI 兑换代币

get_swap_quote

获取兑换报价

API 密钥

工具

描述

list_api_keys

列出你的 API 密钥

create_additional_api_key

创建新的 API 密钥

revoke_api_key

撤销 API 密钥

注意: 市场搜索工具(search_marketsget_marketget_active_markets)可通过 Discovery MCP 使用。

API 格式

服务器在 /mcp 上提供 JSON-RPC 2.0 端点:

curl -X POST https://your-server.com/mcp \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/call",
    "params": {
      "name": "get_balances",
      "arguments": {}
    },
    "id": 1
  }'

MCP 客户端配置

Claude Desktop / Cursor

{
  "mcpServers": {
    "polymarket": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-remote",
        "https://your-server.com/mcp",
        "--header",
        "x-api-key: YOUR_API_KEY"
      ]
    }
  }
}

安全

老用户

出于安全原因,老用户(已有 externalId)在未通过身份验证的情况下无法获取新的 API 密钥。可选方案:

  1. 使用现有 API 密钥 - 如果你已保存

  2. HMAC 身份验证(仅限受信任的机器人)- 使用 BOT_SIGNING_SECRET 签名:

    signature = HMAC-SHA256(externalId:timestamp, BOT_SIGNING_SECRET)
  3. 新账户 - 使用不同的 externalId

开发

# Install dependencies
npm install

# Generate Prisma client
npm run db:generate

# Run migrations
npm run db:push

# Start development server
npm run dev

资源

许可证

本项目采用 PolyForm Noncommercial License 1.0.0 授权。

免费供个人使用、研究和非商业用途。 商业用途需获得 Quantish Inc. 的明确许可。如需商业授权,请联系 hello@quantish.live


Quantish Inc. 构建

A
license - permissive license
-
quality - not tested
D
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    -
    quality
    C
    maintenance
    An MCP server that gives AI agents direct access to Polymarket Crypto prediction markets, enriched with live spot prices. Discover markets, analyze order books, paper trade strategies, track activity, and execute live trades — all through natural language.
    1
    AGPL 3.0
  • A
    license
    -
    quality
    B
    maintenance
    An MCP server and Python toolkit that provides AI agents with real-time tools for Polymarket prediction markets, including liquidity scanning, arbitrage detection, and slippage estimation. It also offers advanced wallet intelligence, portfolio risk calculation, and probabilistic reasoning to enhance market analysis and strategy.
    1
    MIT
  • A
    license
    C
    quality
    B
    maintenance
    MCP server that provides a unified prediction market API for multiple venues like Polymarket and Kalshi, allowing AI agents to discover markets, fetch order books, and execute trades through a single interface.
    32
    438
    8
    MIT
  • A
    license
    -
    quality
    C
    maintenance
    Agent-native, self-hosted MCP server for crypto trading and DeFi management. Enables agents to query balances, execute trades, and manage positions with a policy engine and secure key storage.
    7
    Apache 2.0

View all related MCP servers

Related MCP Connectors

  • No-KYC managed MCP for AI agents: sandboxed TypeScript trading SDK, isolated sub-accounts, futures.

  • HiveCapital MCP Server — autonomous investment layer for AI agents

  • Polymarket + Hyperliquid + macro for AI agents. 38 tools, signal backtest, SSE streaming. Free tier.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/joinQuantish/polymarket-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server