by japp-fi
polymarket mcp server market discovery and analysis via public APIs; optional authenticated trading and portfolio tools when your wallet derives (or supplies) CLOB L2 credentials polymarket mcp server market discovery and analysis via public APIs; optional authenticated trading and portfolio tools when your wallet derives (or supplies) CLOB L2
# Add to your Claude Code skills
git clone https://github.com/japp-fi/polymarket-mcp-serverGuides for using mcp servers skills like polymarket-mcp-server.
Model Context Protocol (MCP) server for Polymarket: market discovery and analysis via public APIs; optional authenticated trading and portfolio tools when your wallet derives (or supplies) CLOB L2 credentials.
Requires Node.js 18+.
| Area | Requires L2 / wallet |
|------|----------------------|
| Resources (polymarket://status, polymarket://config, polymarket://rate-limits) | Partial (status reflects auth) |
| Market discovery (search, trending, categories, …) | No |
| Market analysis (order book, prices, volume, …) | No (some calls use anonymous CLOB) |
| Trading (place/cancel orders, smart trade, …) | Yes |
| Portfolio (positions, PnL, history, …) | Yes |
| Realtime WebSocket subscriptions | User streams need API credentials + auth |
Trading and portfolio handlers are registered only after the CLOB client has L2 credentials (derived from your signing key via deriveApiKey with a createApiKey fallback, or supplied manually — see below).
This codebase does not bundle @jsr/hk__polymarket or fastmcp; Gamma/Data API flows use plain HTTP like the rest of the server.
Feature parity additions inspired by @iqai/mcp-polymarket include: POLYGON_RPC_URL, POLYMARKET_PRIVATE_KEY (alias), CHAIN_ID / CLOB_API_BASE, / , (defaults to GNOSIS-safe style when a funder is set), Gamma tools (, , , tag listing, paginated markets), (Data API), CLOB , , , , optional before mutating trades, and Polygon contract addresses.
No comments yet. Be the first to share your thoughts!
POLYMARKET_FUNDERFUNDER_ADDRESSSIGNATURE_TYPEget_market_by_slugget_event_by_sluggamma_public_searchget_positionsget_balance_allowance / update_balance_allowanceplace_limit_order_token / place_market_order_tokenapprove_allowancesredeem_positionsFrom the repo root:
git clone https://github.com/japp-fi/polymarket-mcp-server
cd polymarket-mcp-server
npm install
npm run build
Development (TypeScript directly):
npm run dev
Production (compiled):
npm start
The server reads environment variables via dotenv (place a .env file in the working directory).
.env.exampleCopy .env.example to .env and fill in values. Never commit real keys.
DEMO_MODE=true skips a funded wallet. Gamma/Data discovery (including get_positions) remains available unless a tool explicitly needs credentials.
Live trading
Provide POLYGON_ADDRESS plus POLYGON_PRIVATE_KEY (or POLYMARKET_PRIVATE_KEY, IQAI-compatible alias). Optionally set POLYGON_RPC_URL (defaults https://polygon-rpc.com) for on-chain approve_allowances / redeem_positions.
Browser-wallet users commonly fund a Polymarket proxy / Safe separately from the EIP-1193 signer. Mirror their env:
POLYMARKET_FUNDER or FUNDER_ADDRESS – USDC custodian address shown in the Polymarket UI (0x…)SIGNATURE_TYPE – 2 selects POLY_GNOSIS_SAFE ordering (the default whenever a non-empty POLYMARKET_FUNDER is present). Use 1 (POLY_PROXY) for Magic-email flows.| Variable | Meaning |
|---------|---------|
| POLYGON_RPC_URL | JSON-RPC endpoint for Polygon (on-chain tooling + faster reads) |
| POLYMARKET_PRIVATE_KEY | Alias of POLYGON_PRIVATE_KEY |
| CHAIN_ID | Overrides POLYMARKET_CHAIN_ID when supplied |
| CLOB_API_BASE | Overrides / fills CLOB_API_URL (IQAI spelling) |
Polymarket’s ApiKeyCreds have three separate fields: key, secret, and passphrase. Set:
| Variable | Maps to |
|----------|---------|
| POLYMARKET_API_KEY | API key (key) |
| POLYMARKET_SECRET | HMAC secret (secret) |
| POLYMARKET_PASSPHRASE | Passphrase (passphrase) |
If you previously used POLYMARKET_API_KEY_NAME as the key string, you can still set only that (with POLYMARKET_API_KEY empty) — it is treated as an alias for key. You must also set POLYMARKET_SECRET and POLYMARKET_PASSPHRASE; the secret and passphrase are not interchangeable.
If any of the three are missing, the server falls back to derive from the wallet (recommended in the official CLOB client README).
Defaults are in src/config.ts. Notable env vars:
MAX_ORDER_SIZE_USD, MAX_TOTAL_EXPOSURE_USD, MAX_POSITION_SIZE_PER_MARKETMIN_LIQUIDITY_REQUIRED, MAX_SPREAD_TOLERANCEENABLE_AUTONOMOUS_TRADING, REQUIRE_CONFIRMATION_ABOVE_USD, AUTO_CANCEL_ON_LARGE_SPREADCLOB_API_URL, GAMMA_API_URL (defaults point at Polymarket production)This server speaks stdio MCP. Example for Cursor mcp.json:
{
"mcpServers": {
"polymarket": {
"command": "node",
"args": ["/absolute/path/to/polymarket-mcp-server/dist/server.js"],
"env": {
"DEMO_MODE": "true"
}
}
}
}
For live trading, remove DEMO_MODE and pass POLYGON_PRIVATE_KEY (or POLYMARKET_PRIVATE_KEY), POLYGON_ADDRESS, optional POLYGON_RPC_URL / POLYMARKET_FUNDER / SIGNATURE_TYPE, and optionally explicit CLOB credentials via env or a .env next to the process working directory.
.env only on trusted machines, and review Polymarket’s own docs for key rotation.MIT (see package metadata).