预测市场服务器

GuessMarket MCP Server为AI代理提供全面的预测市场访问功能,包括发现市场、分析价格、检查链上余额和头寸、构建交易交易和获取智能合约ABI。

  • by hifriendbot
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 hifriendbot/guessmarket-mcp

使用说明

GuessMarket MCP服务器

MCP服务器 GuessMarket 预测市场。使AI代理能够完全访问市场,分析价格,检查链余额和头寸,建立交易交易,并获得智能合约ABI。

在5个EVM链上运行:以太坊、Base、Polygon、BSC和PulseChain。

工具

只读(API)

工具 说明
list_markets 使用状态和链过滤器列出预测市场
get_market 获取详细的市场信息:问题、是/否赔率、交易量、流动性、结束时间
get_market_history 获取带时间戳的价格历史记录以进行趋势分析
get_networks 获取所有支持的带有合约地址的链
get_portfolio 获取钱包在所有市场的交易活动
get_abi 获取智能合约ABI以进行自定义集成

只读(链上)

工具 说明
get_balance 在任何链上获取钱包的稳定币(USDC/USDT)余额
get_allowance 检查市场批准从钱包中支出多少稳定币
get_position 在特定市场上获取钱包的YES股票、NO股票和LP代币

这些工具通过公共RPC端点直接从区块链读取。不需要API密钥。

交易建设者

所有事务构建器都返回未签名的EVM事务对象。用你的钱包签名并广播到链上。金额是人类可读的(例如。 "10.5")并自动转换为每条链的正确小数(USDC为6,BSC USDT为18)。

工具 说明 关键参数
build_approve_tx 批准市场稳定币支出 market_address, amount (或 "max" 无限), chain_id
build_buy_shares_tx 购买“是”或“否”结果股票 market_address, outcome, amount, chain_id, min_shares (滑动)
build_sell_shares_tx 出售“是”或“否”结果股票 market_address, outcome, shares, chain_id, min_usdc (滑动)
build_add_liquidity_tx 添加稳定币流动性,接收LP代币 market_address, amount, chain_id
build_remove_liquidity_tx 销毁LP代币,取回稳定币 market_address, lp_tokens, chain_id
build_claim_winnings_tx 从已解决的市场中索赔奖金 market_address, chain_id
build_create_market_tx 创建新的预测市场 question, end_time (unix时间戳), chain_id
build_buy_with_approval_tx 批准+买入一次通话(返回2笔订单交易) market_address, outcome, amount, chain_id, min_shares (滑动)

防滑保护

build_buy_shares_tx 和 build_sell_shares_tx 接受可选滑动参数(min_shares 和 min_usdc).当设置为 0 (默认),服务器返回警告。设定一个最小值以防止正面跑偏。

贸易流

买股票

1. list_markets               → Find a market to trade
2. get_market                  → Check current odds and liquidity
3. get_balance                 → Check your stablecoin balance
4. get_allowance               → Check if approval is needed
5. build_approve_tx            → Approve stablecoin spending (if needed)
6. build_buy_shares_tx         → Buy YES or NO shares
7. Sign and broadcast transactions with your wallet
8. get_position                → Verify your shares

或者将步骤5-6与 build_buy_with_approval_tx 它按顺序返回两个事务。

出售股份

1. get_position                → Check your share holdings
2. build_sell_shares_tx        → Sell shares back to the market
3. Sign and broadcast the transaction
4. get_balance                 → Verify stablecoin received

提供流动性

1. build_approve_tx            → Approve stablecoin spending
2. build_add_liquidity_tx      → Deposit stablecoin, receive LP tokens
3. get_position                → Verify LP tokens received
4. build_remove_liquidity_tx   → Later: burn LP tokens to withdraw

创造市场

1. build_create_market_tx      → Deploy a new prediction market
2. Sign and broadcast — the new market address is in the tx receipt

交易响应格式

{
  "transaction": {
    "to": "0x...",
    "data": "0x...",
    "chainId": 8453,
    "value": "0x0"
  },
  "description": "Buy YES shares for 10 USDC on market 0x... (Base Mainnet)",
  "meta": {
    "chain": "Base Mainnet",
    "stablecoin": "USDC",
    "outcome": "YES",
    "function": "buyShares(uint8,uint256,uint256)"
  },
  "warnings": []
}

快速入门

克劳德桌面版

添加到您的 claude_desktop_config.json:

{
  "mcpServers": {
    "guessmarket": {
      "command": "npx",
      "args": ["-y", "guessmarket-mcp"]
    }
  }
}

克劳德代码

使用CLI添加到项目中:

claude mcp add guessmarket -- npx -y guessmarket-mcp

或添加到 .mcp.json 在项目根目录中:

{
  "mcpServers": {
    "guessmarket": {
      "command": "npx",
      "args": ["-y", "guessmarket-mcp"]
    }
  }
}

VS Code

添加到您的VS代码设置或 .vscode/mcp.json:

{
  "mcp": {
    "servers": {
      "guessmarket": {
        "command": "npx",
        "args": ["-y", "guessmarket-mcp"]
      }
    }
  }
}

支持的链

链 链ID 稳定币
以太坊 1 USDC(6位小数)
基数 8453 美元(6位小数)
多边形 137 USDC(6位小数)
BSC 56 USDT(18位小数)
PulseChain 369 美元(6位小数)

配置

不需要API密钥-服务器使用公共GuessMarket REST API。

自定义API URL

默认情况下,服务器连接到 https://guessmarket.com/api/guessmarket/v1.用环境变量覆盖:

{
  "mcpServers": {
    "guessmarket": {
      "command": "npx",
      "args": ["-y", "guessmarket-mcp"],
      "env": {
        "GUESSMARKET_API_URL": "https://your-instance.com/api/guessmarket/v1"
      }
    }
  }
}

建筑

AI Agent  <-->  MCP Server  <-->  GuessMarket REST API (market data)
   |                  |
   |                  └───────>  Public RPCs (on-chain reads)
   |                                    |
   |                              5 EVM Chains
   |                          (Ethereum, Base, Polygon,
   |                             BSC, PulseChain)
   |
   └── Signs & broadcasts unsigned transactions on-chain

MCP服务器提供市场数据(通过REST API),读取链上状态(通过公共RPC端点),并构建未签名的事务(通过本地ABI编码)。代理使用自己的钱包签署交易,并直接向区块链广播。

需求

  • Node.js 18或更高版本(使用原生 fetch)

发展

npm install
npm run build
node build/index.js

许可证

麻省理工学院