polymarket-book-mcp

polymarket-book-mcp

Read-only MCP server for Polymarket, providing order books, market metadata, and price history via public GET endpoints. It requires no private keys and cannot place trades.

Category
访问服务器

README

polymarket-book-mcp

An MCP server that reads Polymarket order books, market metadata, and price history.

No private key, no trading, read-only. This package never imports py_clob_client, web3, or eth_account, never reads a wallet key, and never sends a POST or DELETE to any order endpoint. It only issues GET requests to Polymarket's public Gamma and CLOB APIs, the same endpoints the website itself uses to show you a book. There is no code path in here that could place, modify, or cancel an order, because the client that would do that was never written.

Why another one

A survey of existing Polymarket MCP servers turned up two patterns: some require a wallet private key to be configured just to read a public order book, which is a strange amount of trust to ask for a read-only operation; others expose market search or trade history but ship no order-book tool at all, which is the one piece of data a market-making or quoting workflow actually needs first. This package exists to fill that specific gap: order books, cleanly parsed, with no signing key anywhere in the dependency tree.

Install

uv venv
uv pip install -e .

Usage with Claude Code / Claude Desktop

Point the config at the venv's Python interpreter directly:

{"mcpServers": {"polymarket": {"type": "stdio",
  "command": "/absolute/path/to/polymarket-book-mcp/.venv/bin/python",
  "args": ["-m", "polymarket_book_mcp.server"]}}}

Or run it straight from GitHub with uvx, no local clone or install step:

uvx --from git+https://github.com/sunnywlad/polymarket-book-mcp polymarket-book-mcp

Tools

Tool Parameters Description
search_markets query, limit=10, include_closed=False Keyword search via Polymarket's real search backend. Results are interleaved across matching events, so a query like bitcoin returns several distinct events rather than one price ladder's worth of strikes.
get_order_book token_id, depth=10 Live order book for one outcome token: best bid/ask, mid, spread, top N levels per side with cumulative size and notional. The central tool.
get_market url_or_slug Resolve a market URL or slug into its question, condition_id, per-outcome token ids, tick size, LP reward band, and status flags.
get_quote token_id Cheap price check: best_bid, best_ask, mid, spread only.
get_price_history token_id, interval="1d", fidelity=60 Historical price series for one outcome token, plus a min/max/first/last summary.

Data sources

Every network call this server makes, so you can verify it yourself:

  • GET https://gamma-api.polymarket.com/public-search — market/event search (backs search_markets).
  • GET https://gamma-api.polymarket.com/markets?slug=... — slug to conditionId (backs get_market).
  • GET https://clob.polymarket.com/book?token_id=... — live order book (backs get_order_book, get_quote).
  • GET https://clob.polymarket.com/markets/{condition_id} — market/token metadata (backs get_market).
  • GET https://clob.polymarket.com/prices-history?market=... — historical prices (backs get_price_history).

Both APIs are public and require no authentication for these read paths.

Notes on the Polymarket API

A few behaviors worth knowing if you're building on these endpoints yourself, each reproduced directly against the live API:

  • clobTokenIds and outcomes are JSON-encoded strings, not arrays. A Gamma market object contains "clobTokenIds": "[\"5144...\", \"6848...\"]", a string that happens to look like a JSON array, not an actual array. Code that calls .map or iterates on it directly will throw or silently do nothing. It needs a json.loads first, with a fallback for malformed or missing values.
  • GET /markets?search=... is a no-op. It silently ignores the search parameter and returns an unrelated page of markets. The only endpoint that actually implements search is GET /public-search?q=..., the one behind the website's search box.
  • The order book's price levels are not sorted the way you'd expect. GET /book returns both bids and asks in ascending price order. For asks that puts the best price (lowest ask) first, which looks correct and invites indexing asks[0]. For bids, ascending order puts the best price (highest bid) last: bids[0] is the worst bid in the book, not the touch. Both sides need an explicit sort before you can trust [0].
  • events_status=active does not fully filter. /public-search still returns closed markets when asked for active ones, so the market's own closed flag has to be re-checked client-side.
  • One-sided books are normal, not errors. Illiquid, closed, or resolving markets routinely return an empty bids or asks array with HTTP 200. Best bid, best ask, mid, and spread all have to degrade to null rather than raising, and mid/spread need both sides to mean anything.
  • /prices-history takes a token id in a parameter named market. Passing an actual condition_id there returns an empty history with no error, which reads like a market with no trading rather than a bad call.

Note on the MCP Python SDK version

The mcp dependency is pinned >=1.9,<2 deliberately. SDK 2.0.0 removed the Server.list_tools decorator, so any server written against the 1.x low-level API dies at startup with AttributeError: 'Server' object has no attribute 'list_tools'. If you are debugging that error in another MCP server, an unbounded mcp>=1.0.0 pin in its dependencies is very likely the cause.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选