oddsrail
oddsrail
AI 代理用于交易预测市场的轨道。
一个 MCP 服务器,让任何代理(Claude Code、Claude Desktop 或任何兼容 MCP 的工具)都能访问 Polymarket 和 Kalshi 的预测市场:市场搜索、订单簿、价格历史、持仓和订单路由——并在 Polymarket 上实现 链上 builder 代码归因——外加两个高级信号工具(盘中超调/衰减检测、解决争议风险)。
商业模式:路由的订单流赚取 builder 费用;信号工具是付费数据层(计划采用 x402 按次付费)。
为什么选这个而不是 Parsec
最接近的竞争对手(parsecapi.com)是一个闭源托管服务:它存储你的交易所密钥(或持有一个托管钱包为你签名),其 Builder 计划会扣留 builder 收取的 55–85% 的费用。oddsrail 在每个方面都相反:自托管、非托管(密钥永不离开你的机器)、开源,并且你保留 100% 的 Polymarket builder 费用,因为归因使用 Polymarket 的原生机制,而非中间人托管。Parsec 也没有任何信号/分析工具,也没有解决风险相关功能——那是我们的付费层。
Related MCP server: telekash-mcp-server
快速开始
需要 Python 3.11+。
pip install oddsrailclaude mcp add --transport stdio oddsrail -- oddsrail或者从克隆中运行,无需安装:
python3 -m venv .venv && .venv/bin/pip install -r requirements.txtclaude mcp add --transport stdio oddsrail -- /abs/path/to/oddsrail/.venv/bin/python -m oddsrail.server然后让代理:"搜索关于世界杯决赛的市场,并对热门运行超调信号"。
归因如何工作(CLOB V2,2026 年 8 月验证)
在 polymarket.com → 设置 → Builders 获取你的 builder 代码(一个 bytes32)。在那里设置你的费率:taker 最高 100 bps,maker 最高 50 bps——在平台费用之上叠加,结算到你的 builder 钱包。
在服务器运行处执行
export ODDSRAIL_BUILDER_CODE=0x...。任何代理通过
place_order路由的每个订单,在 签名前 都会将代码放入 V2 订单结构体的builder字段——归因在链上,在 CTF Exchange V2 的每个OrderFilled事件中可见。使用
builder_stats工具验证(公共 builder 交易端点 + 排行榜)。
环境变量
变量 | 默认值 | 含义 |
|
|
|
| 未设置 | 你的 bytes32 builder 代码——归因 + 费用。 |
| 未设置 | 操作者钱包密钥;仅真实交易时需要。永不离开此机器。 |
| 未设置 | 代理/存款钱包地址,如果账户使用的话。 |
状态 — 2026-08-23 实时验证
所有 10 个可调用工具均通过真实的 MCP 客户端会话,针对实时 Polymarket 进行了端到端驱动,从芬兰 VPS(/opt/oddsrail)运行。已验证可用:搜索、市场查找、订单簿(9/65 层)、价格历史(361 点)、超调信号、争议风险、builder 排行榜、干跑订单、未结订单、服务器信息。
在那次运行中,字段映射已根据真实 API 进行了修正——文档猜测的形状在三处是错误的(outcomes 是一个以 yes/no 为键的字典,search() 将市场嵌套在事件内,而 book/volume/resolution 数据位于 prices/metrics/state/resolution 子对象中)。
⚠️ 网络说明
Polymarket API 域名在 土耳其网络(BTK)上被屏蔽——本地测试会因阻止页面而 TLS 失败。请在 Polymarket 可访问的地方运行服务器(芬兰 VPS 上的 /opt/oddsrail、VPN 或任何未屏蔽的网络)。信号逻辑和 MCP 层可完全离线测试。
Kalshi(第二个场所)
Kalshi 是 自带密钥且按设计为单租户:操作者提供自己的 API 密钥,交易自己的账户,此服务器不缓存任何内容。这是有意为之——Kalshi 的开发者协议将 API 使用限制为成员自己的交易(§3),禁止促进其他成员的交易(§3.2)和转授权 API(§3.7),并限制存储/共享 API 数据(§3.1)。托管的多人 Kalshi 服务不符合要求;自托管则符合。
这里不存在归因。 Kalshi Builder 代码是 Solana/DFlow/Jupiter 集成——REST API 上没有任何 builder 或联盟字段,因此 Kalshi 订单流无法像 Polymarket 那样被归因或变现。Kalshi 在 oddsrail 中是为了覆盖范围和信号触达,而非路由收入。
此 API 上有两种形状容易出错,因此 oddsrail 对两者进行了规范化:
价格是美元字符串,而非美分(
"0.5600"),大小是定点字符串("10.00");旧的整数美分字段已于 2026 年 3 月移除。所有算术使用Decimal。订单簿两侧都只有买盘。
yes_dollars和no_dollars都是买盘阶梯,升序——因此最佳买价是 最后一个 元素,而 NO 买价 $0.99 就是 YES 卖价 $0.01。kalshi_get_orderbook返回 YES 账簿的传统最佳优先买/卖视图,以及原始阶梯。
订单下达使用自然术语——outcome(yes/no)、action(buy/sell)、price = 该结果的概率——并在内部转换为 Kalshi 的 YES 账簿 bid/ask(买入 NO @ 0.25 变为卖出 @ 0.75)。该转换已进行单元测试,因为这是最容易出现反向持仓错误的地方。
凭据:KALSHI_KEY_ID 加上 KALSHI_PRIVATE_KEY_PATH(PKCS#8 PEM)或 KALSHI_PRIVATE_KEY。设置 KALSHI_DEMO=1 以访问演示环境。读取工具完全不需要密钥。
工具(21)
search_markets、get_market、get_orderbook、price_history、get_positions— 只读,无需密钥overshoot_signal— 高级:新鲜的恐慌跳涨检测 + 此市场的历史回归倾向(从 polymarket-wc 分析器移植)dispute_risk— 高级:透明的 0–100 启发式评分,用于有争议(易受 UMA 争议)的解决place_order、cancel_order、open_orders— 交易,默认干跑builder_stats— 归因验证 + 公共 builder 排行榜server_info— 配置状态,按场所
Kalshi:kalshi_search_markets、kalshi_get_market、kalshi_get_orderbook、kalshi_get_trades、kalshi_balance、kalshi_positions、kalshi_open_orders、kalshi_place_order、kalshi_cancel_order。
技术栈说明
官方统一 SDK
polymarket-client(0.6.x):AsyncPublicClient用于数据,AsyncSecureClient.place_limit_order(..., builder_code=...)用于归因订单。旧的py-clob-client已归档,无法附加 builder 代码——不要使用它。MCP SDK 2.0:
MCPServer来自mcp.server.mcpserver(旧的mcp.server.fastmcp.FastMCP导入在 2.x 中已移除)。Kalshi 使用纯
httpx+cryptography,而非官方 SDK:kalshi-python-sync需要 Python >=3.13,并每周随规范版本同步重新发布。认证是 RSA-PSS(SHA256,盐=摘要长度),基于str(unix_ms) + METHOD + path,其中路径包含/trade-api/v2且排除查询字符串。基础 URL 现在是external-api.kalshi.com。x402(计划中):官方
x402PyPI 包(v2.20+)可以直接包装 MCP 工具(x402.mcp,支付在工具调用的_meta中),但其 MCP 助手目前针对 mcp 1.x——集成意味着固定mcp>=1.28,<2或等待 2.x 兼容版本。主网结算需要促进者(Coinbase CDP:每月 1,000 次免费结算,之后 $0.001)。保留两个信号的免费层,以便注册表可以索引服务器。
builder 经济的样子(实时,2026-08-23)
通过 builder_stats 从公共排行榜拉取:
每周 | 历史总计 | |
#1 (betmoar) | $2.31M | $2.10B |
前 25 名中位数 | $127K | $88.2M |
进入前 25 名 | $42K | $36.8M |
有启发性的行是小型用户:MagicMarkets 以 1 个活跃用户 路由 $354K/周,Gate 以 2 个用户路由 $1.11M/周,PolymarketScan 以 3 个用户路由 $277K。这些是路由自己流量的机器人操作者——正是 oddsrail 的目标客户——它们表明一个认真的代理交易者就能产生可观的交易量。钱包(MetaMask,37K 用户)在用户数量上占主导,而非人均交易量。
路线图
从未屏蔽网络进行实时冒烟测试— 2026-08-23 完成,所有工具通过注册 builder 代码(polymarket.com → 设置 → Builders),启动时费率设为 0 bps,导出
ODDSRAIL_BUILDER_CODE;以极小规模下达第一笔归因订单Kalshi 作为第二个场所— 2026-08-23 完成,9 个工具,实时验证一旦 mcp-2.x 冲突解决,为两个信号添加 x402 付费包装
注册表列表:官方 MCP 注册表(
mcp-publisher,PyPImcp-name:标记)、Smithery(需要公共流式 HTTP 端点 + 一个免费工具供其扫描器使用)、Glama(glama.json)
列表 / 分发
GitHub:https://github.com/hmesutozsoy/oddsrail(公开,MIT)
Glama:自动爬取 GitHub;仓库根目录中的
glama.json声明维护权。官方 MCP 注册表:
server.json已就绪。发布需要先将包发布到 PyPI(注册表通过 PyPI README 中的mcp-name: io.github.hmesutozsoy/oddsrail标记验证所有权),然后执行mcp-publisher login github && mcp-publisher publish。Smithery:需要公共 HTTPS 流式 HTTP 端点——一旦 oddsrail 托管运行而非通过 stdio 本地运行,即可使用。
Available Tools
42 toolsattribution_ledgerARead-onlyIdempotentInspect
Attribution ledger for the builder code in use: every trade carrying it, aggregated per Sunday-start week and per wallet, with the maintainer's own wallets split out into an honest 'external' line. Built from Polymarket's own public builder feed, so any figure it reports can be checked at data-api.polymarket.com/v1/builders/leaderboard.
Inputs: no named parameters.
builder_statsARead-onlyIdempotentInspect
Builder attribution stats: the public builder leaderboard, and (if ODDSRAIL_BUILDER_CODE is set) matched trades attributed to this operator's code.
Inputs: time_period.
cancel_all_ordersADestructiveInspect
KILL SWITCH — cancel every resting Polymarket order on the operator account at once. Use when exposure must go to zero fast. Respects dry-run.
Inputs: no named parameters.
cancel_orderBDestructiveInspect
Cancel an open order by id (respects dry-run).
Inputs: order_id (required).
check_orderARead-onlyIdempotentInspect
CHECK BEFORE YOU PLACE: deterministic verification of a proposed order against the operator's intent, the live market and the guardrails. Pass the operator's own words as intent. Returns ok / caution / block with the evidence per check (market exists and is open, intent matches the market and the YES/NO side, price is sane vs the book, size and $1 minimum, guardrails, liquidity, resolution source) plus a one-line read-back. No model judges anything; nothing is sent.
Inputs: side (required), size (required), price (required), venue (required), +3 more.
closing_soonARead-onlyIdempotentInspect
Markets closing within N hours on either venue, by volume — where trading activity concentrates.
Inputs: hours, limit, venues.
compare_venuesARead-onlyIdempotentInspect
Find markets that may be the SAME event on both Polymarket and Kalshi. NOT an arbitrage scanner: matches are candidates from title similarity plus a close-date check, and a price difference between two candidates is not profit. Identical wording does not mean identical resolution criteria — read both, and run quote_cost on each leg, before acting.
Inputs: query (required), limit, min_similarity, max_close_days_apart.
dispute_riskARead-onlyIdempotentInspect
PREMIUM SIGNAL — dispute-risk triage. Scores 0-100 how likely a market's resolution gets contested (UMA dispute risk) with transparent reasons. Takes the market slug, the Gamma id, or a CLOB token id (the market_id a search returns).
Inputs: id_or_slug (required).
find_marketsARead-onlyIdempotentInspect
Search BOTH Polymarket and Kalshi at once and return one normalised shape per market: venue, market_id (the id that venue's place_order takes), title, yes/no price as probabilities in (0,1), best bid/ask, spread, 24h volume, close time. Use this instead of the per-venue search tools when you do not already know the venue.
Inputs: query (required), limit, venues.
get_marketARead-onlyIdempotentInspect
Get one market's details. Accepts the market slug, the Gamma market id, or either of its CLOB token ids (the market_id that find_markets and search_markets return), so a token id from a search can be passed straight in.
Inputs: id_or_slug (required).
get_orderbookBRead-onlyIdempotentInspect
Get the live orderbook (bids/asks) for a CLOB token id.
Inputs: token_id (required).
get_positionsCRead-onlyIdempotentInspect
Current positions for a wallet address.
Inputs: address (required), limit.
kalshi_balanceARead-onlyIdempotentInspect
Kalshi account balance (needs the operator's API key).
Inputs: no named parameters.
kalshi_cancel_orderADestructiveInspect
Cancel a Kalshi order by id (respects dry-run).
Inputs: order_id (required).
kalshi_get_marketBRead-onlyIdempotentInspect
Get one Kalshi market by ticker.
Inputs: ticker (required).
kalshi_get_orderbookARead-onlyIdempotentInspect
Kalshi orderbook for a ticker, normalised to a YES-book bid/ask view (Kalshi publishes bid ladders only; asks are derived as 1 - NO bid). Raw ladders included.
Inputs: ticker (required), depth.
kalshi_get_tradesBRead-onlyIdempotentInspect
Recent public trades for a Kalshi ticker.
Inputs: ticker (required), limit.
kalshi_open_ordersDRead-onlyIdempotentInspect
Kalshi resting orders (needs the operator's API key).
Inputs: limit.
kalshi_place_orderBDestructiveInspect
Place a Kalshi limit order. State it naturally: outcome yes|no, action buy|sell, price = probability of THAT outcome in (0,1). Translated to Kalshi's YES-book bid/ask internally. DRY-RUN by default.
Inputs: count (required), price (required), action (required), ticker (required), +2 more.
kalshi_positionsDRead-onlyIdempotentInspect
Kalshi positions (needs the operator's API key).
Inputs: limit.
kalshi_search_marketsARead-onlyIdempotentInspect
Search Kalshi markets. Kalshi has no text-search endpoint, so this pages open markets and filters on title/ticker; auto-generated MVE combo shards are excluded. Prices are dollar strings, not cents.
Inputs: limit, query, min_volume.
merge_positionsADestructiveInspect
Merge matching YES+NO shares back into USDC, GASLESS via the relayer. amount is in shares, or 'max' for the largest balanced amount held. Needs the operator's relayer key. DRY-RUN by default.
Inputs: condition_id (required), amount.
my_balanceARead-onlyIdempotentInspect
Authenticated Polymarket cash and allowance snapshot for an existing configured wallet. Cash is separate from positions value; available-to-trade remains unknown until outstanding orders and unsettled fills are reconciled. Requires local account credentials. In simulation use paper_positions.
Inputs: no named parameters.
my_fillsBRead-onlyIdempotentInspect
Recent executions (fills) for the operator wallet — confirms what actually traded, with tx hashes.
Inputs: limit.
my_positionsARead-onlyIdempotentInspect
The operator's current Polymarket positions (uses the configured wallet; no address needed).
Inputs: limit.
open_ordersARead-onlyIdempotentInspect
List the operator wallet's open orders.
Inputs: no named parameters.
order_statusARead-onlyIdempotentInspect
Status of one Polymarket order: resting, partially filled, filled, or gone. The lifecycle answer an agent needs after place_order.
Inputs: order_id (required).
overshoot_signalBRead-onlyIdempotentInspect
PREMIUM SIGNAL — overshoot/fade detector. Analyzes a token's recent price series for fresh panic jumps and reports whether a fade setup is active plus this market's historical reversion tendency.
Inputs: token_id (required), hours, threshold, lookback_s.
paper_positionsARead-onlyIdempotentInspect
Paper-trading portfolio for dry-run: cash, positions at current marks, realized and unrealized P&L, resting paper orders (filled here if the market has crossed them). Dry-run Polymarket orders are papered against the live book automatically. Simulated: no queue, no impact, no fees, so results are an upper bound.
Inputs: no named parameters.
paper_resetADestructiveInspect
Reset the paper-trading ledger to its starting bankroll (ODDSRAIL_PAPER_BANKROLL, default 1000 USDC). Deletes simulated fills and positions; touches nothing real.
Inputs: no named parameters.
place_orderADestructiveInspect
Place a limit order. DRY-RUN by default: returns the order it would post. Real trading needs ODDSRAIL_DRY_RUN=0 and POLYMARKET_PRIVATE_KEY. The operator's builder code is signed into the order. price is the implied probability in (0,1); size is in SHARES (notional = price * size), and the exchange enforces a $1 minimum notional on marketable orders. post_only=True rejects rather than crosses the book.
Inputs: side (required), size (required), price (required), token_id (required), +1 more.
position_sizeARead-onlyIdempotentInspect
Fractional-Kelly position size for a binary contract, given your bankroll, the market price, and YOUR fair value estimate. Caps at a fraction of full Kelly and refuses negative-edge bets. Returns its assumptions — subtract quote_cost before trusting the number.
Inputs: price (required), fair_value (required), bankroll_usd (required), max_fraction_of_kelly.
price_historyBRead-onlyIdempotentInspect
Recent price history for a CLOB token id: hours back, at fidelity_minutes resolution.
Inputs: token_id (required), hours, fidelity_minutes.
quote_costARead-onlyIdempotentInspect
What a given size would ACTUALLY cost, by walking the order book rather than reading the top level. Returns average fill price, slippage vs best, notional, and the levels consumed — plus the venue's fee schedule where it publishes one. Call this before sizing any trade, and on both legs before acting on a cross-venue gap.
Inputs: side (required), size (required), venue (required), market_id (required).
redeemable_positionsARead-onlyIdempotentInspect
What the operator can turn back into USDC now: redeemable (resolved, winning) positions and mergeable (hold both YES and NO) positions, with the ids the gasless tools take. Uses the configured wallet.
Inputs: limit.
redeem_positionsADestructiveInspect
Redeem the winning shares of a RESOLVED market for USDC, GASLESS via the relayer. Pass exactly one of condition_id or market_id. Needs the operator's relayer key. DRY-RUN by default.
Inputs: market_id, condition_id.
resolution_criteriaARead-onlyIdempotentInspect
READ BEFORE TRUSTING A PRICE: the full resolution contract for a market — what exactly resolves YES, who resolves it, from which sources. venue is 'polymarket' (pass the slug, the Gamma id, or the market_id a search returned, which is a CLOB token id) or 'kalshi' (pass the ticker).
Inputs: venue (required), market_id (required).
search_marketsARead-onlyIdempotentInspect
Search Polymarket markets by text (Gamma public-search under the hood); empty query lists open markets. Returns token ids, prices, metrics, resolution info.
Inputs: limit, query.
server_infoARead-onlyIdempotentInspect
Server status: dry-run state, attribution config, enabled capabilities, venue reachability from this machine, and Polymarket's geoblock verdict for this machine's IP (advisory — not a compliance check). Call this before the first order of a session.
Inputs: no named parameters.
settlement_auditARead-onlyIdempotentInspect
Settlement-divergence audit for a cross-venue pair, on LIVE data (no pre-curated pair list). Compares close times, resolution sources, UMA dispute status and market structure, and returns ok / caution / block with reasons. polymarket_id takes the slug, the Gamma id or the market_id a search returned (a CLOB token id); kalshi_ticker takes the ticker. Run this before treating any cross-venue price difference as an edge.
Inputs: kalshi_ticker (required), polymarket_id (required), notional_usd.
split_positionADestructiveInspect
Split USDC collateral into a full YES+NO share set for one market, GASLESS via Polymarket's relayer. amount_usdc is collateral in USDC (e.g. 25). Needs POLYMARKET_RELAYER_API_KEY and POLYMARKET_RELAYER_API_KEY_ADDRESS (polymarket.com -> Settings -> Relayer API keys). DRY-RUN by default. Never falls back to a gas-paying broadcast.
Inputs: amount_usdc (required), condition_id (required).
watch_bookARead-onlyIdempotentInspect
Stream one Polymarket token's realtime market events (book snapshot, price changes, trades) for up to seconds (1-60) or max_events, then return them. Use after get_orderbook when you need to see the book MOVE before acting; a quiet market may deliver only the initial snapshot.
Inputs: token_id (required), seconds, max_events.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 42 tools
The venue prefixes (kalshi_ vs no prefix) and action nouns keep most tools distinct. Only mild overlaps exist—notably find_markets vs search_markets vs kalshi_search_markets, and my_positions vs get_positions—but the descriptions clarify when to use each. No tools are truly indistinguishable.
Names are consistently lowercase snake_case and mostly follow a predictable venue_action_noun pattern, e.g. kalshi_place_order, get_orderbook, cancel_all_orders. A few noun-style names like server_info, builder_stats, and position_size break the verb-first feel, but there is no chaotic style mixing.
42 tools is well beyond the 25+ threshold for 'too many' and feels heavy even for a two-venue trading platform. Many tools could be consolidated or grouped, such as search variants, position variants, and several signal/analysis utilities. The breadth is real, but the count creates selection overhead.
The toolkit is broad: market discovery, order placement/cancellation, balances/positions, paper trading, redemption, resolution checks, builder attribution, and cross-venue settlement audits are all covered. Minor gaps include Kalshi-specific order status/fill history and a dedicated Polymarket trade history tool, so agents may need to work around those edges.
Maintenance
Related MCP Connectors
Calibrated world model for AI agents. 40 tools: world state, markets, trading. Kalshi + Polymarket.
Your agent needs the crowd's number — live odds on elections, policy, macro prints and sport, from the venues where people put money behind the opinion. **What you can ask for** • "What are the current odds on this event?" • "List the open markets on this topic across both venues." • "Show recent trades and how the price moved." • "What is the implied probability now versus a week ago?" **How to use it** Point any MCP client at https://mcp.aisa.one/prediction-market-data/mcp and sign in with OAuth — there is no key to create or paste. 5 tools: Kalshi markets and trades, Polymarket markets, events and activity. **Why this rather than the source** Both venues in one shape, so the same question can be priced twice. **It is also a door to the rest** The same login reaches 26 sources and 580+ operations. Read the odds here, then ask the same agent for the market data or the news behind them — without adding a second server. **What it costs** Finding and inspecting an operation is free. Running one is billed per call at API prices, with no seat and no monthly minimum, and every call takes max_price_usd so an agent cannot overspend by accident. **Where else it reaches** https://mcp.aisa.one/finance/mcp for equities, crypto and prediction markets in one place.
Polymarket & Kalshi live prediction market odds aggregator and cross-venue arbitrage scanner MCP.
Polymarket in your AI: market rules, real fill costs, who is trading, top traders. Read-only.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceReal-time prediction market intelligence for AI agents. Query Polymarket and Kalshi markets, wallet profiles, smart money leaderboards, social pulse signals, price candlesticks, and orderbook data — 13 agents, one MCP connection. Powered by 1.1TB+ of historical data.MIT
- AlicenseAqualityDmaintenancePrediction market probability oracle for AI agents. 26 tools across 500+ live markets from Kalshi and Polymarket. Cross-source arbitrage detection, structured TPF signals, Kelly Criterion sizing, agent performance tracking, and webhook alerts.9250 npm1MIT
- AlicenseNot gradedqualityBmaintenanceAn 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.71 PyPI1MIT
- AlicenseAqualityCmaintenanceEnables AI agents to discover and analyze prediction markets, execute trades, and manage positions on Polymarket via the Model Context Protocol.7169 npm22MIT