Polymarket Agent MCP
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Polymarket Agent MCPfind markets on the next Fed rate cut and summarize the odds"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Polymarket Agent MCP
MCP server that lets a local AI client read Polymarket markets and, when you turn live mode on, place orders with your wallet. Version 1.7.0. Node.js 20 or newer. MIT license.
The process starts in preview. Preview writes simulated trades to a local SQLite file and does not sign or send orders. Live mode signs CLOB orders with POLY_PRIVATE_KEY and posts them to https://clob.polymarket.com. One process, one database, one wallet. It is a single-operator tool.
Stdio is the transport for Claude Code, Cursor, and other local MCP clients. HTTP is optional and should stay on a private network.
Capability details: PERMISSIONS.md and SECURITY.md.
What a call does
The client invokes a tool. Inputs are checked with Zod.
Read tools call the public Polymarket APIs, or ESPN when the tool is
wta.discover.Trade tools run the safety checks, then the daily budget check.
In preview, the trade row is stored as
simulated.In live,
TradeExecutorbuilds a CLOB client, derives API credentials from the signing key, and callscreateAndPostOrder. The position row is stored asexecutedonly after the CLOB accepts the order.
config.go_live flips the running process to live after confirm: true, and only if the live credentials are set. A restart returns to COPY_MODE from the environment.
Related MCP server: Crocodile
Install
npm install -g polymarket-agent-mcpFrom this repository:
git clone https://github.com/polytutor-ai/polymarket-mcp-agent.git
cd polymarket-agent-mcp
npm install
npm run build
npm testClaude Code, in ~/.claude/settings.json:
{
"mcpServers": {
"polymarket": {
"command": "npx",
"args": ["polymarket-agent-mcp"]
}
}
}Copy .env.example to .env beside the package when you want a budget other than the defaults, or when you want live trading. The loader reads .env from the package root, not from the process working directory.
Modes
Mode | How it starts | Orders |
Preview | Default. | Simulated rows in SQLite |
Live |
| Signed CLOB orders |
Live startup requires all four of these to be non-empty:
POLY_PRIVATE_KEY=
POLY_API_KEY=
POLY_API_SECRET=
POLY_API_PASSPHRASE=
POLY_FUNDER_ADDRESS=
COPY_MODE=liveThe executor signs with POLY_PRIVATE_KEY and then calls createOrDeriveApiKey(). The CLOB client is constructed with signature type 1 and POLY_FUNDER_ADDRESS as the funder, which matches a Polymarket proxy wallet. CHAIN_ID defaults to 137 (Polygon).
Keys stay in the process config. They are not written to SQLite. Error text that looks like a long hex key is redacted before it is logged. The designated order host is clob.polymarket.com.
Copy monitor
monitor.start polls watched wallets on an interval (default 30 seconds, allowed range 10–300). Each tick reads recent BUY activity from data-api.polymarket.com. A trade is eligible when it is newer than the monitor’s max age and its USDC size is at least MIN_CONVICTION (default $3). The copy size is then limited by the remaining daily budget (DAILY_BUDGET, default $20).
monitor.stop clears that loop. The watchlist survives in SQLite.
watchlist.rebalance drops watched addresses that fail the performance rules in that tool. traders.backtest replays a wallet’s past trades locally and does not send orders.
Safety limits
config.safety_limits stores limits in the config table. Defaults until you change them:
Limit | Default |
| $50 |
| $200 |
| $100 |
| $50 |
| 0.10 |
orders.buy rejects a ticket that would exceed max order size, total recorded exposure, or the per-market total. Market-quality checks used by buy and the monitor look at spread, depth, and price range separately. Stop-loss and take-profit levels are stored with positions.set_exit_rules and evaluated when something calls positions.check_exits. They are not a background loop of their own.
Network
Host | When |
| Market search, metadata, resolution |
| Leaderboard, positions, wallet activity |
| Books, prices, and live order writes |
| Public prices after |
| Today’s WTA scoreboard inside |
HTTP reads use a 10 second timeout and up to two retries. The websocket sends a public market subscription. It does not send the wallet key. There is no analytics or update-check client in this package.
HTTP transport
HTTP starts when the process is given --http or when PORT is set. The Docker image does both: CMD is node dist/index.js --http and PORT=3000.
node dist/index.js --http
PORT=8080 node dist/index.jsPath | Role |
| Streamable HTTP MCP |
|
|
| Discovery card |
| Name, version, and the paths above |
MCP_API_KEY, when set, requires Authorization: Bearer <token> on /mcp. When it is unset, /mcp accepts any caller who can open the port. The listen socket is all interfaces. Keep HTTP on localhost, or set MCP_API_KEY and do not publish the port.
docker build -t polymarket-mcp .
docker run -p 127.0.0.1:3000:3000 \
-v mcp-data:/app/data \
-e COPY_MODE=preview \
-e DAILY_BUDGET=20 \
-e MCP_API_KEY=replace-me \
polymarket-mcpA release image is published as ghcr.io/demwick/polymarket-agent-mcp:1.7.0.
docker compose up builds the local Dockerfile, mounts ./data at /app/data, and sets preview mode. The Compose file does not publish port 3000. The container still runs the HTTP command from the Dockerfile. Add a ports mapping yourself if you want to reach it from the host.
SQLite path: DB_PATH, default ./copytrader.db, or /app/data/copytrader.db in the image. The file holds the watchlist, trades, daily budget, safety config, exit rules, and agent-cycle notes. It does not hold the signing key.
Configuration
Variable | Default | Role |
|
|
|
|
| USDC ceiling for the UTC day |
|
| Smallest source trade, in USDC, that the monitor will copy |
| empty | Signer. Required for live |
| empty | Required to pass the live credential check |
| empty | Required to pass the live credential check |
| empty | Required to pass the live credential check |
| empty | Proxy funder on the CLOB client |
|
| Chain id passed to the CLOB client |
| empty | Bearer token for |
|
| SQLite file |
| unset | Setting it enables HTTP on that port |
config.set can change daily_budget and min_conviction in the database while the process is running. It cannot change the signing key or COPY_MODE.
Tools
Forty-eight tools are registered in src/index.ts. Names below are the MCP tool ids.
Markets
Tool | Behavior |
| Keyword search |
| Markets by end date and category |
| Ranked by 24h, 7d, or 30d volume |
| Liquid markets in a category such as politics, sports, or crypto |
| Markets related to a topic or condition |
| Markets that belong to one event |
| Bid, ask, mid, spread |
| History and a text sparkline, from 1 hour to 1 month |
| Spread, depth, and price-range quality |
| Largest holders |
| Two to five markets side by side |
| Heuristic BUY, SELL, or HOLD from price, quality, and recent momentum. No external LLM |
| YES plus NO prices that fail to sum near 1 |
| Saved markets and price-alert levels |
| Live CLOB websocket subscription |
| Today’s WTA matches from ESPN, matched to Polymarket slugs, with a suggested discount bid |
| Limit bid at that discount. Preview unless the process is live |
| Markets where several leaderboard wallets are buying |
Traders and copy
Tool | Behavior |
| Leaderboard by PnL, volume, and ROI. Optional |
| Profile, win rate, and PnL for one address |
| 0–100 score across the dimensions implemented in |
| Open positions for one address |
| Local replay of copying that address |
| Add or remove an address |
| Current watchlist |
| Remove addresses that fail the rebalance rules |
| Start the copy loop |
| Stop the copy loop |
Orders and positions
Tool | Behavior |
| Buy outcome shares for a condition id. Minimum amount $0.50 |
| Sell an open position |
| Up to 10 orders in one call |
| Cancel all open CLOB orders. Requires a live client |
| Open orders |
| One order by id |
| Open and closed rows |
| Close one local position |
| Store stop-loss and take-profit prices |
| Evaluate those rules and market resolution |
| Switch this process to live. |
Portfolio and config
Tool | Behavior |
| Collateral view, budget, and PnL |
| Open positions grouped by watched wallet |
| Concentration and limit warnings from recorded trades |
| Suggestions for |
| Text dashboard |
| Filtered trade log |
|
|
| Read or update the limits above |
| Append a note to |
Two prompts are registered for clients that support them: daily-trading-cycle and evaluate-trader. They return a checklist of tool calls. They do not place orders by themselves.
Layout
src/
index.ts # tool registration, stdio, HTTP
constants.ts # Polymarket base URLs
tools/ # one module per tool
services/ # executor, monitor, books, backtest, WTA
db/ # SQLite schema and queries
utils/ # config, safety, fetch, loggingLogs go to stderr so stdio MCP can keep stdout for JSON-RPC. The last 500 lines are also kept in memory and can be forwarded to the MCP client as logging messages.
Scripts
npm run build # tsc
npm start # node dist/index.js
npm run start:http # node dist/index.js --http
npm test # vitest
npx tsc --noEmit # typecheck; CI runs this before publishpackage.json engines require Node.js >=20. prepublishOnly runs the TypeScript build. The only install scripts in the lockfile are better-sqlite3 (native module) and optional macOS fsevents.
This server cannot be deployed
Maintenance
Related MCP Connectors
AI prediction market trading — real-time data, CLOB exchange, Prop Desk, 40+ tools
Polymarket in your AI: market rules, real fill costs, who is trading, top traders. Read-only.
Read-only Hyperliquid data for AI agents: fills, candles, funding, liquidations, wallet analytics.
Trade Papertrade BTC and ETH perps from Claude, ChatGPT, Codex, Cursor and any MCP client.
Related MCP Servers
- FlicenseAqualityBmaintenanceAI-agent ready FastMCP server for Polymarket market discovery, wallet analytics, and public CLOB data, providing a read-only interface for querying markets, wallets, and order books.2239 PyPI-
- AlicenseNot gradedqualityAmaintenanceEnables querying and replaying deterministic market data for crypto and US equities from a local Parquet lake via natural language.3Apache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to trade on Polymarket prediction markets via a self-hosted MCP server, supporting wallet management, order placement, position syncing, and gasless transactions on the Polygon network.10 npmPolyForm Noncommercial 1.0.0
- FlicenseBqualityCmaintenanceEnables paper and live trading on Polymarket five-minute BTC, ETH, SOL, and XRP Up/Down markets, with order execution, Chainlink TWAP data, SQLite audit history, and optional automatic local stop-losses.21-