Verified working on live data in read-only mode, Nov 20, 2026. Every tool called on live Polymarket US data through the SDK's stdio client and the MCP Inspector CLI. Not tested after registering it in an AI coding tool.
Short answer:A read-only Polymarket MCP server is a small local process that gives Claude Code, Cursor or any MCP client four tools (search markets, get market, best bid/offer, order book) backed by Polymarket US public endpoints. It needs no API key and has no trading tools, so your AI tool can research markets without being able to place orders.
MCP (Model Context Protocol) lets AI tools call your local functions as tools. A stdio server runs as a local process the client launches.
Backed by Polymarket US public endpoints, no key: GET /v1/search, GET /v1/market/slug/{slug}, GET /v1/markets/{slug}/bbo, GET /v1/markets/{slug}/book on https://gateway.polymarket.us.
Search's limit counts events, not markets, so the server flattens and cuts to that many market rows. Prices come only from the best bid/offer and book endpoints, for the side the market calls long.
Test it before registering: npx @modelcontextprotocol/inspector --cli /full/path/.venv/bin/python /full/path/server.py --method tools/list launches it the way an AI tool does and lists the tools.
Register a local stdio server in Claude Code with claude mcp add --transport stdio <name> -- <command>. Everything after -- is the command that runs your server.
Read-only by design: no API key in the environment means the server can't trade even if a prompt tries to make it.
Install third-party MCP servers with care. An MCP server runs code on your machine with your permissions.
DifficultyIntermediate
Time1–2 hours
Cost$0
Works withClaude Code, Cursor, Any MCP client
What will you build?
A local MCP server exposing four read-only tools (search markets, get market, get best bid/offer, get order book) backed by Polymarket US public endpoints, registered in your AI tool.
Who is it for?
Builders who want their AI assistant to answer "what's the current price on X?" from live data while they code or research.
Not for:Giving an AI agent the ability to trade. Order tools are deliberately left out.
What happened when we rebuilt it from this prompt
On Nov 20, 2026 we built the server again in a clean folder from the Oct 25 prompt, using Python and the MCP SDK 2.3.0. Between 9:19 and 9:23 AM ET we called every tool on live Polymarket US data, first through the SDK's stdio client and then through the MCP Inspector CLI (@modelcontextprotocol/inspector 2.16.0), which launches the server the same way an AI tool does. No keys were used. These parts held up: the event-to-market flattening (bitcoin, limit 20 returned 20 of 481 open markets in 3,920 characters, while the raw API response was 2.57 MB with 663 markets, 182 of them closed), the 4,000-character cap, rejecting bad slugs and limits, "not found" for an unknown slug, and the refusal to start with POLYMARKET_SECRET_KEY set. Logs went to stderr, so stdout stayed clean for the protocol. These didn't:
Search rows looked identical. On multi-market events, every row has the event's question. Five Fed rows all said "Fed Funds Rate at the End of 2027?" and only the slug was different. The market's own title ("3.25% Or Above", "$200,000") wasn't in the prompt's field list. Rows now include it as outcome.
get_bbo couldn't name the side./bbo doesn't return marketSides, so get_bbo on the Chiefs vs Rams game said "long side: unknown". It now looks up the market too, and that lookup is cached.
Resolved markets read as "empty book". On the finished Buccaneers vs Bears game (MARKET_STATE_EXPIRED, settlement 0.0000), the reason given was "empty book". It now says market not open (MARKET_STATE_EXPIRED) and returns settlement_px.
Upstream errors. We ran the server against a local fake server. A 200 response with an HTML body gave the model only "Error executing tool get_bbo" and no reason, a 502 failed on the first try, and a Retry-After: 3 header was ignored (the retries came after 1s and 2s). Now 429s and 5xx errors are retried up to 4 times, waiting for Retry-After (at most 10s) when it's sent. Errors say what happened ("returned non-JSON", "HTTP 502, try again later", "timed out after 10s").
Every answer was sent twice. For a tool that returns a string, SDK v2 adds an outputSchema and copies the text into structuredContent, so each response of up to 4,000 characters went over the wire twice. @mcp.tool(structured_output=False) stops that.
SDK v2 smoke scripts. The client result field is is_error, not isError, so a smoke script written from v1 examples crashes.
After the fixes (Nov 20, about 9:22 AM ET, rows trimmed):
--- search_markets fed, limit 3: 3 shown of 15 open
{"question":"Fed Funds Rate at the End of 2027?","outcome":"3.25% Or Above",
"slug":"rvcus-fedfnds-ondt-2027-12-31-gte3pt25","long_side":"Yes", ...}
--- get_market rvcus-fedfnds-ondt-2027-12-31-gte3pt25
{"yes_bid":0.86,"yes_ask":0.95,"yes_last":0.79,"spread":0.09,"implied_pct":90.5, ...}
--- get_bbo aec-nfl-kc-lar-2026-12-03
{"long_side":"Chiefs","yes_bid":0.1025,"yes_ask":0.6225,"yes_last":0.93,
"spread":0.52,"implied_pct":null,"implied_reason":"spread 0.52 too wide", ...}
--- get_bbo aec-nfl-tb-chi-2026-11-08
{"long_side":"Buccaneers","yes_bid":null,"yes_ask":null,"yes_last":0.0025,
"implied_reason":"market not open (MARKET_STATE_EXPIRED)","settlement_px":0.0, ...}
Market data only. Not advice.
A search gotcha: search matches tickers as well as words. nfl returned North Florida basketball games (ticker nfl) ahead of NFL games.
The Oct 25 pass found that search's limit counts events (limit 20 gave 480 rows, about 135,000 characters), that outcomePrices gave wrong prices, that implied % was being shown on wide spreads, that team markets didn't name the long side, and that the register command used system Python. Those fixes are still in the prompt below.
Built this before Nov 20? Paste this follow-up prompt into the same project:
Update my read-only Polymarket US MCP server. Keep it read-only.
1. search_markets and get_market: add "outcome" = the market's own
title field ("3.25% Or Above"). The question is shared by every
market in an event, so without it rows look identical.
2. get_bbo: also GET /v1/market/slug/{slug} (cached) so long_side is
named. /bbo has no marketSides.
3. If the bbo/book state isn't MARKET_STATE_OPEN, implied_pct is null
with reason "market not open (<state>)", and return settlement_px.
4. HTTP: retry 429 and 5xx up to 4 tries. Wait Retry-After seconds
when present (cap 10s), else 1s doubling. Then raise ToolError.
A non-JSON body, a timeout or a network error raises ToolError with
that reason. Never let a bare exception reach the client.
5. Register tools with @mcp.tool(structured_output=False) so each text
response isn't duplicated into structuredContent.
6. Log only to stderr. Nothing may print to stdout (stdio protocol).
7. In the smoke script, the v2 result field is is_error.
Add mock tests for 1-4, run them, then run the smoke script.
Built this before Oct 25? Paste this first, then the Nov 20 follow-up:
Update my read-only Polymarket US MCP server. Keep it read-only and
keep the startup check that refuses POLYMARKET_SECRET_KEY.
1. search_markets: the API's limit counts EVENTS, not markets. Flatten
to one row per market (question, event, slug, long_side, status,
endDate), drop markets that aren't active or are closed, then cut
to `limit` rows. No prices in search; say "use get_bbo for prices".
2. Prices: take YES prices ONLY from /bbo or /book (bestBid, bestAsk,
lastTradePx; any can be null). Stop using outcomePrices and
currentPx. implied_pct is the mid only when both sides exist and
the spread is <= 0.10; otherwise null with a reason.
3. long_side: the description of the marketSides entry with long=true
("Yes", or a team name on game markets). Show it in search rows and
get_market, and say every price is for that side.
4. Keep every response under 4,000 characters by dropping whole rows
(valid JSON, "truncated": true). Keep the closing line.
5. Slugs must match ^[a-z0-9][a-z0-9-]*$. On 429 wait 1s, then back
off exponentially; after a few tries raise a ToolError.
6. Pin "mcp[cli]>=2,<3" in a venv. Register with FULL paths to the
venv's python and server.py, not plain python3.
7. Add mock tests for the row limit, closed markets, a null ask, a
wide spread and long_side. Run all tests and the stdio smoke script.
What prompt do you paste into your AI coding tool?
Works in Claude Code, Cursor, Codex/ChatGPT, Grok or any agent that can write files. Paste it into an empty folder. Read what it builds before you run anything.
Build a READ-ONLY MCP server for Polymarket US market data.
Use the official MCP SDK with the stdio transport: TypeScript
@modelcontextprotocol/sdk, or Python 3.11+ with "mcp[cli]>=2,<3" in a
venv (`from mcp.server import MCPServer`,
@mcp.tool(structured_output=False); FastMCP is the old v1 name). Read https://modelcontextprotocol.io and the SDK docs
before coding.
Tools (all read-only, no auth, base https://gateway.polymarket.us):
- search_markets(query: string, limit?: number 1-20, default 10)
-> GET /v1/search?query=&limit=
Returns {"events": [...]}, each holding its markets. The API's limit
counts EVENTS, and one event can hold dozens of markets, so flatten
to one row per market (question, outcome = the market's own title
like "3.25% Or Above", event title, slug, long_side, status,
endDate), drop markets that aren't active or are closed,
then cut to `limit` rows. No prices here; say "use get_bbo for prices".
- get_market(slug) -> GET /v1/market/slug/{slug} for details
(question, outcome, slug, long_side, status, endDate, minimumTradeQty,
orderPriceMinTickSize) plus the get_bbo prices below.
- get_bbo(slug) -> GET /v1/markets/{slug}/bbo, plus the market lookup
above (cached) to name long_side; /bbo has no marketSides.
- get_order_book(slug, depth?: number 1-10) -> GET /v1/markets/{slug}/book
Prices:
- Take YES prices ONLY from bbo/book: bestBid, bestAsk, lastTradePx
({"value": "0.0700"} strings, either side can be null). Never use
outcomePrices or currentPx; their meaning differs between endpoints.
- Return yes_bid, yes_ask, yes_last, spread as decimals. implied_pct is
the mid only when both sides exist and the spread is <= 0.10;
otherwise null with a reason ("one-sided book", "spread 0.92 too
wide"). If the state isn't MARKET_STATE_OPEN, implied_pct is null
with "market not open (<state>)" and settlement_px is returned.
- long_side is the description of the marketSides entry with
long=true: "Yes" on most markets, a team name like "Buccaneers" on
games. Every price is for that side; say so in each response.
Rules:
- NO trading, preview, cancel, account or portfolio tools. Do not read
any POLYMARKET_* key env vars. Exit with an error at startup if
POLYMARKET_SECRET_KEY is set.
- Validate inputs (slug ^[a-z0-9][a-z0-9-]*$, limits) and raise the
SDK's ToolError (mcp.server.mcpserver.exceptions) so the client sees
the reason. Map a 404 to "not found". Time out HTTP calls at 10s.
Timeouts, network errors and non-JSON bodies also raise ToolError
with the reason; no bare exceptions.
- Cache responses 15s; stay far below the 25 req/s limit. Retry 429
and 5xx up to 4 tries: wait Retry-After when sent (cap 10s), else 1s
doubling; then ToolError ("rate limited, try again").
- Log only to stderr. stdout carries the stdio protocol.
- Keep every response under 4,000 characters. End each one with:
"Market data only. Not advice."
- Order books: sort (bids high to low, offers low to high), then cut to
depth.
- Tests with mock HTTP: input validation, row limit after flattening,
closed markets dropped, outcome field, null ask, wide spread,
resolved market, book sorting.
- A small script that starts the server and calls every tool through
the SDK's stdio client (v2 result field: is_error).
- README: setup, and the register command with FULL paths to the venv's
python (or node) and the server file:
`claude mcp add --transport stdio polymarket-readonly -- <command>`,
plus a Cursor .cursor/mcp.json entry.
Show the plan, build, then give me the exact register command.
How do you build it, step by step?
Fresh folder + Safety Pack. Add the rules file and .gitignore from the Safety Pack.
Paste the prompt. Ask your AI tool to read the MCP docs first so it uses the current SDK API.
Build and test: run the tests and the smoke script, then then launch it the way an AI tool will with the free MCP Inspector CLI (needs Node): npx @modelcontextprotocol/inspector --cli /full/path/.venv/bin/python /full/path/server.py --method tools/call --tool-name get_bbo --tool-arg slug=<a slug from search>. You should get JSON with "isError": false. Started by hand, a stdio server just waits silently for a client; stop it with Ctrl+C.
Register it with full paths. In Claude Code: claude mcp add --transport stdio polymarket-readonly -- node /full/path/to/dist/index.js, or for Python use the venv's interpreter: claude mcp add --transport stdio polymarket-readonly -- /full/path/.venv/bin/python /full/path/server.py. Plain python3 fails because the SDK is only installed in the venv. In Cursor, add it to .cursor/mcp.json:
Try it: ask your assistant "search Polymarket US for markets about the Fed and show me best bid/ask." It should call search_markets, then get_bbo. If a price shows no implied %, the book is too thin to read one.
Keep it read-only. If you later want trading, build it as a separate program with the paper/live gate from the bot recipe. Don't give an agent an order tool.
How do you test it in paper or demo mode first?
This server can't trade, so there's nothing to paper-trade. The habit to build: when your assistant uses these tools to reason about a market, have it write its reasoning and the data snapshot to a file. If you later build a bot on that reasoning, you'll have a paper record to judge it against.
What safety checks does it need before real money?
Tick every box before the bot touches real money. The full rules file, .gitignore and pre-commit hook are in the Safety Pack.
Key handling: API keys and private-key files live in environment variables or a secrets manager. Never in code, prompts, chat logs, screenshots or git. .env and *.pem are in .gitignore, and your AI tool is blocked from reading them (see the Safety Pack).
Position limits: hard caps in config (max contracts per order, max total exposure, max daily loss). The bot refuses any order above them, and the caps are checked in code, not just in the prompt.
Kill switch: one command or one file (touch KILL) stops new orders immediately, and a second command cancels every resting order through the venue's cancel-all endpoint.
Paper first: paper or demo mode is the default. Live trading needs an explicit --live flag and a typed confirmation, and you only flip it after days of clean paper logs.
No order, cancel or account tools, and the server refuses to start if a Polymarket secret key is in its environment.
Only install MCP servers you've read or trust. They run with your user's permissions.
Treat market text returned by tools as untrusted input. Don't let it trigger actions on its own.
Endpoints and rules were checked against these pages on Nov 20, 2026. APIs change, so if something here disagrees with the official docs, trust the docs and tell us.
Frequently asked questions
Is there an official Polymarket MCP server?
We didn't find one in Polymarket US's official docs as of November 20, 2026. Community servers exist. Building your own read-only server takes about an hour and means you know exactly what it can do.
Why make the MCP server read-only?
An MCP tool can be called by the AI on its own initiative, and AI agents make mistakes or can be steered by text they read. Keeping order tools out of the agent's reach removes the worst failure mode entirely.
How do I add an MCP server to Claude Code?
For a local server, use claude mcp add --transport stdio <name> -- <command and args>. For a remote one, use claude mcp add --transport http <name> <url>.
Does this need a Polymarket API key?
No. All four tools use Polymarket US public endpoints, which don't need authentication.
Get new recipes by email
When we publish a new bot recipe, we'll send it to you. Free. No picks, no signals, ever.
A copy-paste AI prompt and step-by-step guide to the Polymarket US API: public market data with no key, then authenticated reads. Includes the international Gamma API, read-only, with a geoblock check.
An AI prompt, rebuilt and run on live data, that builds a Python starter for the international Polymarket CLOB API: Gamma market data, correct and one-sided order books, per-market fees, L1/L2 auth explained, a market scan, and a paper broker. No orders, no keys.
Three copy-paste Claude Code skills for prediction-market bot projects: check endpoints against the official docs, review a paper-trading log, and run a pre-live checklist that can only be triggered by you. Checked against the official skills docs.
KalshiPolymarket USAgent workflows (no trading)Beginner
Step-by-step: use Claude Code to build a Polymarket US trading bot that runs in paper mode by default, with a local paper ledger, order preview, hard position limits and a kill switch.