TypeScriptADK-TS

MCP Polymarket

Access and trade on Polymarket prediction markets using your wallet.

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-polymarket

Use 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

VariableRequiredDescription
FUNDER_ADDRESSYesAvailable from the user menu dropdown on polymarket.com (different from login wallet)
POLYMARKET_PRIVATE_KEYYesPrivate key of the wallet that interacts with Polymarket

Credentials

To get your Polymarket credentials:

  1. Create an account at polymarket.com and connect a wallet
  2. Click on your user menu — your Funder Address is shown in the dropdown (it differs from your login wallet address)
  3. Use the private key of the wallet you want to use for trades as POLYMARKET_PRIVATE_KEY

Available Tools

get_market_by_slug
slug:string

Description

Get detailed information about a specific market by its slug identifier. The slug can be extracted from the Polymarket URL.

get_event_by_slug
slug:string

Description

Get detailed information about a specific event by its slug identifier. Events group multiple related markets.

list_active_markets
limit:numberoffset:number

Description

List all currently active markets with pagination. Returns markets that are not yet closed.

search_markets
query:string

Description

Search for markets, events, and profiles using text search.

get_markets_by_tag
tag_id:stringlimit:numberclosed:boolean

Description

Get markets filtered by a specific tag ID. Useful for finding markets in specific categories.

get_all_tags

No parameters

Description

Get a list of all available tags for categorizing markets.

get_order_book
token_id:string

Description

Get the current order book for a specific market token. Shows all active buy and sell orders.

approve_allowances
waitForConfirmations:integer

Description

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_order
tokenId:stringprice:numbersize:numberside:stringorderType:string

Description

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_order
tokenId:stringamount:numberside:stringorderType:string

Description

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_orders
market:string

Description

Get all open orders for the authenticated account. Can optionally filter by market.

get_order
orderId:string

Description

Get details of a specific order by its ID.

cancel_order
orderId:string

Description

Cancel a specific order by its ID.

cancel_all_orders

No parameters

Description

Cancel all open orders for the authenticated account.

get_trade_history
market:stringmaker_address:string

Description

Get trade history for the authenticated account. Can optionally filter by market or maker address.

get_balance_allowance
assetType:stringtokenID:string

Description

Get balance and allowance information for the authenticated account. Can check COLLATERAL or CONDITIONAL tokens.

update_balance_allowance
assetType:stringtokenID:string

Description

Update balance and allowance for the authenticated account. Required before trading.

redeem_positions
conditionId:stringtokenId:stringoutcomeIndex:numbernegRisk:boolean

Description

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_positions
user:stringlimit:number

Description

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);

Further Resources