polymarket-mcp-server
caiovicentino/polymarket-mcp-server
- Type
- MCP server
- Scanned
- Nov 17, 2026
- Version
- 21f65f319ff0
- Files read
- 270
This tool connects AI assistants to Polymarket so they can research prediction markets, watch live prices, and place or cancel real-money trades using your Polygon cryptocurrency wallet. The biggest risk is that hidden instructions in market text could trick the AI into draining your wallet with unwanted trades, since the AI can approve orders by itself and the built-in spending limits fail to count your existing positions or open orders.
What it can reach
- Secrets
- Reads your Polygon wallet private key, wallet address, and Polymarket API credentials from environment variables or a .env file to sign trades and authenticate requests.
- Network
- Connects over the internet to Polymarket API and live-data servers (including clob.polymarket.com, gamma-api.polymarket.com, and data-api.polymarket.com) and can run an optional local web dashboard on port 8080.
- Files
- Reads and updates local .env configuration files, writes server log files, and edits Claude Desktop's claude_desktop_config.json file during setup.
- Other
- Places, rebalances, and cancels real-money prediction market orders using USDC in your Polygon wallet.
Findings
-
HighTotal and per-market USD exposure limits are bypassed due to API field mismatch and uncounted open orders
src/polymarket_mcp/tools/trading.py:1396
Before placing a trade, create_limit_order fetches the user's positions from data-api.polymarket.com/positions and converts them in _convert_positions to enforce MAX_TOTAL_EXPOSURE_USD and MAX_POSITION_SIZE_PER_MARKET. However, Polymarket's Data API returns camelCase keys (curPrice, avgPrice, conditionId, asset), whereas _convert_positions reads non-existent snake_case keys (current_price, avg_price, market, asset_id), causing every held position to be valued at $0.00 with an empty market ID. Resting unfilled orders are also ignored, so an AI agent tricked by prompt injection in market text can place repeated orders up to MAX_ORDER_SIZE_USD until the wallet is emptied. The same key mismatch in rebalance_position also treats existing positions as $0.00 and buys duplicate exposure.
Fix: Parse the real Polymarket Data API fields (curPrice, avgPrice, conditionId, asset) in _convert_positions and rebalance_position, and include open resting orders from get_orders() when computing total and per-market exposure.
-
HighOrder confirmation gate is a tool parameter controlled by the AI agent rather than the user
src/polymarket_mcp/tools/trading.py:327
The documentation and configuration describe ENABLE_AUTONOMOUS_TRADING=false (the default) and REQUIRE_CONFIRMATION_ABOVE_USD as requiring human confirmation before placing orders. In code, confirmation is gated solely on confirm=True, a regular boolean argument in the MCP tool schema that the AI agent itself supplies, and unconfirmed responses explicitly instruct the caller to call again with confirm=true. Unless the user's MCP client independently prompts before every tool execution, malicious instructions embedded in a market title or description can make the agent pass confirm=true directly and execute unauthorized trades.
Fix: Enforce order confirmation outside the LLM's tool arguments—for example via MCP client tool-approval settings, an out-of-band approval prompt, or a one-time confirmation token shown only to the user.
-
MediumUnauthenticated local web dashboard lacks Origin, Host, and CSRF checks on configuration updates
src/polymarket_mcp/web/app.py:486
When the optional polymarket-web dashboard is running on 127.0.0.1:8080, POST /api/config rewrites trading safety limits in .env without any password, CSRF token, Origin check, or Host header check. Because FastAPI parses request bodies as JSON when the Content-Type header is omitted (such as a browser fetch with an untyped Blob) and allows DNS rebinding when Host is unchecked, any malicious website the user visits while the dashboard is open can silently enable autonomous trading and raise MAX_ORDER_SIZE_USD and MAX_TOTAL_EXPOSURE_USD in .env. Cross-origin webpages can also connect directly to /ws without an Origin check to read connection status.
Fix: Require an authentication token on dashboard HTTP and WebSocket endpoints, validate Host and Origin headers to reject cross-origin and DNS-rebinding requests, and require an explicit JSON Content-Type with CSRF protection on POST /api/config.
-
LowGUI setup wizard and install scripts enable autonomous trading by default
Although version 0.2.0 changed PolymarketConfig and .env.example to default ENABLE_AUTONOMOUS_TRADING to false for safety, setup_wizard.py unconditionally writes ENABLE_AUTONOMOUS_TRADING=true into .env with no UI toggle to turn it off. Likewise, install.sh and install.bat default ENABLE_AUTONOMOUS_TRADING to true (including when the user declines custom safety limits), letting an AI agent place real orders below REQUIRE_CONFIRMATION_ABOVE_USD on the first call without even hitting the two-step confirm flag.
Fix: Default ENABLE_AUTONOMOUS_TRADING to false in setup_wizard.py, install.sh, and install.bat, and add an explicit opt-in checkbox with a clear warning in the setup wizard.
-
LowInstall scripts expose the wallet private key in process arguments and world-readable files
During full-mode setup, install.sh passes POLYGON_PRIVATE_KEY as a command-line argument to python3 when updating claude_desktop_config.json, briefly exposing the raw private key in the operating system process table (ps) to any other local user or process. In addition, both install.sh and setup_wizard.py create .env and claude_desktop_config.json (plus .backup copies) without restricting permissions to 0600, leaving the wallet private key readable by other local users under typical default umasks.
Fix: Pass secrets to the Python helper via environment variables or standard input instead of command-line arguments, and create .env, claude_desktop_config.json, and backup files with 0600 permissions (umask 077).
-
LowServer shutdown automatically cancels all open Polymarket orders by default and ignores .env
src/polymarket_mcp/server.py:338
Whenever the MCP server exits or restarts (such as closing Claude Desktop or Cursor), shutdown() checks os.getenv('CANCEL_ON_SHUTDOWN', 'true') and calls cancel_all_orders(), cancelling every open order across all markets on the user's Polymarket account, including orders placed manually on polymarket.com. This behavior is undocumented in README.md and .env.example, and because pydantic-settings does not export .env entries into os.environ, setting CANCEL_ON_SHUTDOWN=false in .env has no effect.
Fix: Add CANCEL_ON_SHUTDOWN to PolymarketConfig with a safe default of False, document it in .env.example and README.md, and read config.CANCEL_ON_SHUTDOWN during shutdown.
-
LowQuickstart script clones and executes an unpinned repository branch
When run outside an existing checkout (including via the README's curl | bash one-liner), quickstart.sh clones the mutable main branch from GitHub without pinning a release tag or commit hash and immediately executes ./install.sh --demo.
Fix: Pin quickstart.sh and README installation instructions to a specific signed release tag or commit SHA.
