MCP Polymarket
Access and trade on Polymarket prediction markets using your wallet.
- Package:
@iqai/mcp-polymarket - Provider: Polymarket
Overview
The Polymarket MCP server gives your agent access to Polymarket, a leading decentralized prediction market. It can fetch active markets, retrieve current prices and liquidity, query positions, and place or cancel orders — enabling agents to interact with prediction markets programmatically.
Wallet Required
Trading on Polymarket requires a funded wallet and your funder address. Keep your private key secure and never commit it to source control.
Getting Started
Install the package:
pnpm add @iqai/mcp-polymarketUse the server in your agent:
import { McpPolymarket } from "@iqai/adk";
const toolset = McpPolymarket({
env: {
FUNDER_ADDRESS: process.env.POLYMARKET_FUNDER_ADDRESS,
POLYMARKET_PRIVATE_KEY: process.env.POLYMARKET_PRIVATE_KEY,
},
});
const tools = await toolset.getTools();import { McpToolset } from "@iqai/adk";
const toolset = new McpToolset({
name: "Polymarket MCP Client",
description: "Client for Polymarket prediction markets",
transport: {
mode: "stdio",
command: "npx",
args: ["-y", "@iqai/mcp-polymarket"],
env: {
FUNDER_ADDRESS: process.env.POLYMARKET_FUNDER_ADDRESS,
POLYMARKET_PRIVATE_KEY: process.env.POLYMARKET_PRIVATE_KEY,
PATH: process.env.PATH || "",
},
},
});
const tools = await toolset.getTools();{
"mcpServers": {
"polymarket-mcp-server": {
"command": "npx",
"args": ["-y", "@iqai/mcp-polymarket"],
"env": {
"FUNDER_ADDRESS": "your_polymarket_funder_address",
"POLYMARKET_PRIVATE_KEY": "your_wallet_private_key"
}
}
}
}Environment Variables
| Variable | Required | Description |
|---|---|---|
FUNDER_ADDRESS | Yes | Available from the user menu dropdown on polymarket.com (different from login wallet) |
POLYMARKET_PRIVATE_KEY | Yes | Private key of the wallet that interacts with Polymarket |
Credentials
To get your Polymarket credentials:
- Create an account at polymarket.com and connect a wallet
- Click on your user menu — your Funder Address is shown in the dropdown (it differs from your login wallet address)
- Use the private key of the wallet you want to use for trades as
POLYMARKET_PRIVATE_KEY
Available Tools
get_market_by_slugslug:string
get_market_by_slugDescription
Get detailed information about a specific market by its slug identifier. The slug can be extracted from the Polymarket URL.
get_event_by_slugslug:string
get_event_by_slugDescription
Get detailed information about a specific event by its slug identifier. Events group multiple related markets.
list_active_marketslimit:numberoffset:number
list_active_marketsDescription
List all currently active markets with pagination. Returns markets that are not yet closed.
search_marketsquery:string
search_marketsDescription
Search for markets, events, and profiles using text search.
get_markets_by_tagtag_id:stringlimit:numberclosed:boolean
get_markets_by_tagDescription
Get markets filtered by a specific tag ID. Useful for finding markets in specific categories.
get_all_tagsNo parameters
get_all_tagsNo parameters
Description
Get a list of all available tags for categorizing markets.
get_order_booktoken_id:string
get_order_bookDescription
Get the current order book for a specific market token. Shows all active buy and sell orders.
approve_allowanceswaitForConfirmations:integer
approve_allowancesDescription
Grant the USDC and Conditional Tokens approvals required to trade on Polymarket. Automatically approves only the contracts that don't already have approvals set. Includes both regular and NegRisk markets. These approvals are standard ERC20/ERC1155 approvals, revocable at any time in your wallet.
place_ordertokenId:stringprice:numbersize:numberside:stringorderType:string
place_orderDescription
Place a limit order on Polymarket at a specific price. Specify the number of shares (size) and price (0-1). For both BUY and SELL, you specify the number of shares you want to trade. Example: size=10, price=0.6 means buy/sell 10 shares at $0.60 per share (total: $6).
place_market_ordertokenId:stringamount:numberside:stringorderType:string
place_market_orderDescription
Place a market order that executes immediately at current market price. IMPORTANT: For BUY orders, amount is the dollar amount ($USD) you want to spend. For SELL orders, amount is the number of shares to sell. Example: amount=5, side=BUY means 'spend $5 to buy shares at market price'.
get_open_ordersmarket:string
get_open_ordersDescription
Get all open orders for the authenticated account. Can optionally filter by market.
get_orderorderId:string
get_orderDescription
Get details of a specific order by its ID.
cancel_orderorderId:string
cancel_orderDescription
Cancel a specific order by its ID.
cancel_all_ordersNo parameters
cancel_all_ordersNo parameters
Description
Cancel all open orders for the authenticated account.
get_trade_historymarket:stringmaker_address:string
get_trade_historyDescription
Get trade history for the authenticated account. Can optionally filter by market or maker address.
get_balance_allowanceassetType:stringtokenID:string
get_balance_allowanceDescription
Get balance and allowance information for the authenticated account. Can check COLLATERAL or CONDITIONAL tokens.
update_balance_allowanceassetType:stringtokenID:string
update_balance_allowanceDescription
Update balance and allowance for the authenticated account. Required before trading.
redeem_positionsconditionId:stringtokenId:stringoutcomeIndex:numbernegRisk:boolean
redeem_positionsDescription
Redeem (claim) winnings from a resolved Polymarket prediction market. Use this to collect USDC from positions in markets that have been settled. For regular markets, you need the conditionId. For negative risk markets, you also need the tokenId and should set negRisk=true.
get_positionsuser:stringlimit:number
get_positionsDescription
Get all positions for a wallet address with current values. Returns position details including size, current price, current value, and P&L. Uses the Polymarket Data API for accurate position valuation.
Integration Example
import { AgentBuilder, McpPolymarket } from "@iqai/adk";
import * as dotenv from "dotenv";
dotenv.config();
async function main() {
// Initialize McpPolymarket toolset
const toolset = McpPolymarket({
env: {
FUNDER_ADDRESS: process.env.POLYMARKET_FUNDER_ADDRESS,
POLYMARKET_PRIVATE_KEY: process.env.POLYMARKET_PRIVATE_KEY,
},
});
// Get available McpPolymarket tools
const polymarketTools = await toolset.getTools();
// Create agent with McpPolymarket tools
const { runner } = await AgentBuilder.create("polymarket_agent")
.withModel("gemini-2.5-flash")
.withDescription(
"A prediction market agent that monitors and trades on Polymarket",
)
.withTools(...polymarketTools)
.build();
const response = await runner.ask(
"What are the top 5 markets by volume on Polymarket today, and what are their current prices?",
);
console.log(response);
}
main().catch(console.error);