Polymarket MCP server

Give an AI agent the Polymarket archive and a backtest engine. The marketlens MCP server runs as a local command over stdio, so Claude Code, Claude Desktop, Cursor, and any other MCP client can search markets, read the order book as it was at any moment, pull trades and candles, and write and run a strategy against real books, all in conversation. It ships inside the Python SDK; the setup reference is in the docs.

903,238
markets
37.9B
order book rows
280M
trades
207M
candles
March 1, 2026
complete since

Install and connect

bash
$ pip install 'marketlens[mcp]'

Then register the command with your client. The same JSON works in claude_desktop_config.json, in Claude Code's MCP settings, and in Cursor; the only secret is the API key, free from the console.

json
{ "mcpServers": { "marketlens": { "command": "marketlens-mcp", "env": { "MARKETLENS_API_KEY": "mk_..." } } } }

The 15 tools

Find
search_markets, get_market, search_events, search_series

Markets by question, series slug, category, status, or window; events and recurring series.

Read
get_orderbook, get_orderbook_metrics, get_trades, get_candles

The L2 book at any past instant with spread, microprice, and imbalance; bucketed metrics; executed trades; OHLCV from 1s to 1d.

Derive
get_signals, get_surface, get_reference_candles

Implied probability surfaces over multi-outcome markets; Binance spot for the underlying asset.

Test
strategy_reference, run_backtest, compare_backtests, open_backtest

The strategy API so the agent writes correct code, then runs it against real books, scores variants, and reopens saved runs.

Data tools return compact rows and every market carries its data_start and data_end, so the agent picks windows from facts rather than guesses. Backtests run in a subprocess with a hard timeout; set MARKETLENS_MCP_DISABLE_BACKTEST=1 to keep the server read only.

What a session looks like

Ask for a strategy in plain words: "Buy YES on BTC 5 minute markets when the midpoint drops below 0.35, 200 shares, liquidate at resolution, replay the afternoon of August 1." The agent calls strategy_reference, writes the Strategy class, runs run_backtest on the series slug and window, and reports return, win rate, and Sharpe with the saved run path. Ask it to try a threshold of 0.30 and it calls compare_backtests. Every fill came from the recorded book, with queue priority, latency, and Polymarket fees applied.

Community MCP servers and this one

Several open source Polymarket MCP servers wrap the official APIs and are good for live questions: what is trading now, the current book, recent activity. They cannot answer what the book looked like yesterday, because the official APIs do not keep it. This server reads the recorded archive, 903,238 markets since March 1, 2026, and adds the backtest engine on top. Use a live wrapper for now and this one for then.

Common questions

Is there a Polymarket MCP server?

Yes. The marketlens MCP server (pip install 'marketlens[mcp]', command marketlens-mcp) gives any MCP client 15 tools over the Polymarket archive: search markets, events, and series, read the order book at any past instant, trades, candles, order book metrics, implied probability surfaces, Binance reference prices, and run, compare, and reopen backtests. It covers 903,238 markets since March 1, 2026.

How do I add the Polymarket MCP server to Claude or Cursor?

Install the extra, then add a server entry with command marketlens-mcp and MARKETLENS_API_KEY in its env to claude_desktop_config.json, the Claude Code MCP settings, or Cursor's MCP settings. It speaks stdio, so any MCP client that launches a local command works.

How is it different from the community Polymarket MCP servers on GitHub?

Most community servers wrap Polymarket's live APIs: current markets, the current book, recent trades. This server reads recorded history (the book at any past moment, every trade, candles, outcomes) and can write and run a backtest against real order books, which no live wrapper can do.

What does it cost?

The server is part of the open source SDK. The API key behind it has a free tier of 600 requests per minute and 25 million data rows per day, no card required; each tool call bills the rows it returns.

Try it

Your agent, the whole archive

Fifteen tools over every book, trade, and candle since March 2026, plus backtests. The free tier includes 25M rows per day, no card required.

bash
$ pip install marketlens