Repository avatar
Search & Data Extraction
v0.1.1
active

polymarket-agent

com.tensorust/polymarket-agent

Search Polymarket, read order books and prices, and place or cancel CLOB v2 orders from your agent

Documentation

polymarket-agent

Polymarket for AI agents. One Rust binary that is both a CLI and an MCP server: search markets, read books and prices, place and cancel CLOB v2 orders, list positions. No Node, no Python, one cargo install.

cargo install polymarket-agent

Use it from any agent

Shell (Claude Code, Codex, Cursor agents, cron jobs, your own loop):

polymarket-agent search "fed rate cut" --limit 3
polymarket-agent price 20882952001141190985444129909954556515852282417019672850316979275117126535717
polymarket-agent book  20882952001141190985444129909954556515852282417019672850316979275117126535717 --depth 5
polymarket-agent limit 2088...5717 buy 0.05 100            # GTC limit: token, side, price, shares
polymarket-agent limit 2088...5717 buy 0.05 100 --dry-run  # sign only, print the order, send nothing
polymarket-agent market-order 2088...5717 buy 25           # FOK market buy for 25 USDC
polymarket-agent orders | cancel <id> | cancel-all | trades | positions

Every command prints JSON.

MCP (Claude Desktop, Claude Code, Cursor, Windsurf, anything that speaks MCP over stdio):

{
  "mcpServers": {
    "polymarket": {
      "command": "polymarket-agent",
      "args": ["mcp"],
      "env": { "POLYMARKET_PRIVATE_KEY": "0x..." }
    }
  }
}

Claude Code one-liner: claude mcp add polymarket -e POLYMARKET_PRIVATE_KEY=0x... -- polymarket-agent mcp

Tools exposed: search_markets, get_market, get_orderbook, get_price, check_geoblock, place_limit_order, place_market_order, cancel_order, cancel_all_orders, list_open_orders, list_trades, get_positions, builder_attribution.

Keys and wallets

  • Read-only commands need nothing.
  • Trading needs POLYMARKET_PRIVATE_KEY: the hex private key of the Polygon EOA that signs orders. The key never leaves your machine; it signs EIP-712 orders locally and derives Polymarket L2 API credentials on first use.
  • Polymarket proxy or Safe wallets (accounts created on polymarket.com with email or a browser wallet): set POLYMARKET_FUNDER to the proxy wallet address shown on your profile and POLYMARKET_SIGNATURE_TYPE to proxy or safe. Plain EOA users leave both unset.
  • Funds: the trading wallet needs pUSD (or USDC) on Polygon with the exchange allowances set. Set them once on polymarket.com or with the official SDKs.

Builder attribution (read this)

Every order this tool signs carries a Polymarket builder code in the order's builder field. The default is Tensorust's code:

0xa1101e5f6b3f69288122de5e489cd6574d9b4fc4b7bc7482de0c66b7e9193c96

That attributes the volume to the Tensorust builder profile under the Polymarket Builder Program, and Polymarket adds a builder fee to taker fills (Tensorust's rate is 0.25 percent taker, 0 maker; it is public on the profile). It is how this tool is paid for.

You can change it in one env var:

  • POLYMARKET_BUILDER_CODE=0x<your code> attributes volume to your own builder profile (create one at polymarket.com, Settings, Builders).
  • POLYMARKET_BUILDER_CODE=0x0000000000000000000000000000000000000000000000000000000000000000 attributes to nobody and pays no builder fee.

polymarket-agent builder-code prints the code in effect. polymarket-agent limit ... --dry-run shows the exact signed order so you can see the field yourself.

Geoblocking

Polymarket rejects orders from blocked regions and asks builders to check location before sending. Trading commands call Polymarket's own geoblock endpoint first and refuse to send if it says blocked; polymarket-agent geoblock shows the answer for your machine. This tool does nothing to work around that.

Library

use polymarket_agent::Agent;

let agent = Agent::new()?;                 // reads POLYMARKET_PRIVATE_KEY if present
let hits = agent.search("fed rate cut", 3).await?;
let book = agent.book("2088...5717", 10).await?;
let fill = agent.limit("2088...5717", "buy", "0.05", "100", false, false).await?;

Built on the official polymarket_client_sdk_v2 and rmcp crates.

Status

v0.1: CLOB v2, Gamma search, Data API positions, stdio MCP. Not yet: websockets, perps, combos, the gasless relayer. Issues and PRs welcome.

Made by Tensorust.

MCPB
https://github.com/Mattbusel/polymarket-agent/releases/download/v0.1.1/polymarket-agent-mcp-0.1.1.mcpb
Install Command
# mcpb: https://github.com/Mattbusel/polymarket-agent/releases/download/v0.1.1/polymarket-agent-mcp-0.1.1.mcpb