Skip to main content
Glama
PlayAINetwork

Polymarket MCP Server

Polymarket MCP Server

A Model Context Protocol (MCP) server that provides AI assistants with the ability to interact with Polymarket.

Features

  • Market Discovery: Browse and search current prediction markets

  • Real-time Data: Get detailed market information, prices, and statistics

  • Trading: Place market orders (FOK/FAK) and limit orders (GTC/GTD)

  • Portfolio Management: View balances, positions, and P&L

  • Order Management: Track and manage your active orders

  • Multi-format Support: Works with market slugs or direct token IDs

Related MCP server: Polymarket MCP Server

Installation

1. Clone and Install

git clone https://github.com/yourusername/polymarket-mcp-server.git
cd <folder-name>
pnpm install

2. Install Required Dependencies

pnpm install @modelcontextprotocol/sdk zod @polymarket/clob-client ethers

3. Environment Configuration

Create a .env file in the project root:

# Required: Your Polygon wallet private key
PRIVATE_KEY=your_private_key_here

# Optional: Custom CLOB API URL (defaults to https://clob.polymarket.com)
CLOB_API_URL=https://clob.polymarket.com

# Optional: Signature type (defaults to 0)
SIGNATURE_TYPE=0

# Optional: Existing API credentials (will be auto-generated if not provided)
CLOB_API_KEY=your_api_key
CLOB_SECRET=your_secret
CLOB_PASS_PHRASE=your_passphrase

4. MCP Configuration

Add the server to your MCP settings file:


{
  "mcpServers": {
    "poly": {
      "command": "npx",
      "args": ["polymarket-mcp"],
      "env": {
        "PRIVATE_KEY": ""
      }
    }
  }
}

Available Tools

1. Market Discovery

getAllMarkets

Get current prediction markets with optional filtering.

Get me today's trending markets

getMarketDetails

Get detailed information about a specific market using its slug.

Get details for the market "will-donald-trump-win-the-2024-us-presidential-election"
Show me info about "bitcoin-above-100k-by-end-of-2024"

2. Trading Operations

placeMarketOrder

Execute immediate market orders (Fill or Kill / Fill and Kill).

Buy $100 of YES on "bitcoin-above-100k-by-end-of-2024" using FOK order
Sell $50 of NO on the Trump election market with FAK

Parameters:

  • marketSlug or tokenID: Market identifier

  • outcome: YES or NO (if using marketSlug)

  • amount: USD amount to trade

  • side: BUY or SELL

  • orderType: FOK (Fill or Kill) or FAK (Fill and Kill)

placeLimitOrder

Place limit orders at specific prices (Good Till Cancelled / Good Till Date).

Place a limit buy order for 100 shares at $0.65 on the Bitcoin market
Set a GTC sell order for 50 shares at $0.80 on Trump election

Parameters:

  • marketSlug or tokenID: Market identifier

  • outcome: YES or NO (if using marketSlug)

  • price: Price per share (0-1)

  • size: Number of shares

  • side: BUY or SELL

  • orderType: GTC (Good Till Cancelled) or GTD (Good Till Date)

  • expirationMinutes: Expiration time (GTD only)

3. Portfolio Management

getPortfolio

View complete portfolio including balances and positions.

Show me my portfolio
What's my current P&L?
Check my USDC balance

getOrder

Get details of a specific order by ID.

Check order status for 0x831680cb77da95792af5a052c87c8abf9d2ae5cb21f275670bc0ff58f2823c5c

Usage Examples

Starting the Server

Important: Always run the server using Node.js directly to ensure proper initialization:

node <path-to-index.js>

This will:

Initialize your wallet connection Set up required token allowances (USDC approvals for CTF and Exchange contracts) Generate or use existing API credentials Start the MCP server

Basic Market Research

"Get details about the market 'ai-will-achieve-agi-by-2025'"

Simple Trading

"Buy $20 of YES on 'will-spacex-reach-mars-by-2030' using a market order"

Portfolio Monitoring

"Show me my current portfolio and P&L"

"Check my USDC balance on Polymarket"

Advanced Trading

"Set a GTC limit sell order for 100 shares at $0.85 on token ID 123456"

"Place a FOK buy order for $500 on the climate change market"

"Check the status of my order 0x831680..."

Market Slug Examples

Market slugs are found in Polymarket URLs:

  • https://polymarket.com/event/will-donald-trump-win-the-2024-us-presidential-election

    • Slug: will-donald-trump-win-the-2024-us-presidential-election

  • https://polymarket.com/event/bitcoin-above-100k-by-end-of-2024

    • Slug: bitcoin-above-100k-by-end-of-2024

API Limits

  • Polymarket may have rate limits on API calls

  • Large orders may have slippage on smaller markets

  • Some markets may have low liquidity

Troubleshooting

Common Issues

"Client not initialized"

  • Check your PRIVATE_KEY is set correctly

  • Ensure you have USDC balance for gas fees

  • Verify Polygon network connectivity

"Market not found"

  • Double-check the market slug spelling

  • Ensure the market is still active

  • Try using direct token ID instead

"Insufficient balance"

  • Add USDC to your Polygon wallet

  • Check if allowances were set properly

  • Verify you're on Polygon Mainnet

"Order failed"

  • Check if market is still open for trading

  • Verify price is within valid range (0-1)

  • Ensure sufficient balance for the trade

API Reference

Market Data Endpoints

  • Gamma API: https://gamma-api.polymarket.com/markets

  • Data API: https://data-api.polymarket.com/positions

  • CLOB API: https://clob.polymarket.com

Contract Addresses (Polygon)

  • USDC: 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174

  • CTF: 0x4D97DCd97eC945f40cF65F87097ACe5EA0476045

  • Exchange: 0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E

Contributing

  1. Fork the repository

  2. Create a feature branch (git checkout -b feature/amazing-feature)

  3. Commit your changes (git commit -m 'Add amazing feature')

  4. Push to the branch (git push origin feature/amazing-feature)

  5. Open a Pull Request

Support

Available Tools

6 tools
getAllMarketsC

Get all markets from today

ParametersJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of markets to fetch (default: 20)

TDQS

C2.8/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, and the description only indicates a read-like operation. It does not disclose rate limits, pagination behavior, or the effect of the limit parameter beyond what's in the schema.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single short sentence, which is concise but lacks substance. It says no more than the tool name implies, making it minimally helpful.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simple input, the description omits return format, ordering, and timezone context for 'from today'. Without output schema, these gaps reduce completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with description for 'limit'. The description adds no additional meaning beyond what the schema provides, earning the baseline score.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Get all markets from today' with a specific verb and resource, and implies a scope. It distinguishes from sibling 'getMarketDetails' which likely targets a single market, but does not explicitly differentiate.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like 'getMarketDetails'. The description lacks context on use cases, prerequisites, or exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

getMarketDetailsB

Get detailed information about a specific market using Gamma API

ParametersJSON Schema
NameRequiredDescriptionDefault
marketSlugYesMarket slug from the URL (e.g., 'will-donald-trump-win-the-2024-us-presidential-election')

TDQS

B3.3/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must carry the full burden. It only says 'Get detailed information', which implies a read operation, but does not disclose other behavioral traits like auth requirements or side effects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence that is front-loaded with the key verb and resource. No extraneous information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, so the description should hint at return values. It says 'detailed information', which is vague but acceptable for a simple read tool with one parameter. It adequately covers the tool's purpose but lacks specificity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% for the single parameter marketSlug, and its description in the schema is clear. The tool description adds no additional meaning beyond the schema, earning a baseline 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it retrieves detailed information for a specific market, with a specific verb 'Get' and resource 'detailed information about a specific market'. It distinguishes itself from siblings like getAllMarkets which returns all markets.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives such as getAllMarkets. The description only states what it does without providing context for selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

getOrderA

Get details of a specific order by order ID

ParametersJSON Schema
NameRequiredDescriptionDefault
orderIdYesThe order ID to retrieve details for (e.g., '0x831680cb77da95792af5a052c87c8abf9d2ae5cb21f275670bc0ff58f2823c5c')

TDQS

A3.8/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full burden. It correctly indicates a read operation (Get details) without side effects, but does not disclose permissions, rate limits, or error conditions. Adequate for a simple retrieval.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence of 11 words, verb-first, no filler. Perfectly concise and front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given simple single-parameter tool with no output schema or annotations, the description covers basic purpose. Could mention returned fields or common error cases, but not essential for this complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% with a clear example for orderId. The description adds no extra meaning beyond 'by order ID', so baseline 3 applies. No additional parameter insights provided.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states verb 'Get', resource 'details of a specific order', and identifier 'order ID'. It distinguishes from sibling tools like getAllMarkets and placeLimitOrder which operate on different resources or actions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Description implies usage when an order ID is known, but no explicit guidance on when to use versus alternatives like getMarketDetails or getPortfolio. No exclusions or when-not-to-use mentioned.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

getPortfolioA

Get complete portfolio including account balance and all positions

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

TDQS

A4.3/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It correctly indicates a read operation ('Get'), but lacks details on permissions, data freshness, or any side effects. For a simple read tool, it is adequate but not comprehensive.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence that is concise, front-loaded with the action and resource, and contains no unnecessary words. Every word adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given zero parameters, no output schema, and a straightforward purpose, the description completely covers what the tool does. Sibling tools provide context for differentiation, and the description suffices for an agent to select correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has no parameters, and the input schema covers 100% (empty). The description adds no parameter info, which is acceptable since none exist. Baseline for zero parameters is 4.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('Get') and resource ('complete portfolio'), clearly indicating the tool retrieves all portfolio data including balance and positions. It distinguishes from siblings like 'getOrder' (single order) and 'getMarketDetails' (market info).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for retrieving a full portfolio overview, and sibling tools handle specific tasks (orders, markets), providing clear context. However, no explicit when-not to use or alternative suggestions are given.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

placeLimitOrderC

Place a limit order (Good Till Cancelled / Good Till Date)

ParametersJSON Schema
NameRequiredDescriptionDefault
sideYesOrder side - BUY or SELL
sizeYesSize in shares to trade
priceYesPrice per share (between 0 and 1)
outcomeNoMarket outcome to bet on - YES or NO (required if using marketSlug)
tokenIDNoDirect token ID for the market outcome (alternative to marketSlug+outcome)
tickSizeNoTick size for the market (auto-detected if using marketSlug)
orderTypeYesOrder type - GTC (Good Till Cancelled) or GTD (Good Till Date)
marketSlugNoMarket slug from the URL (e.g., 'fordow-nuclear-facility-destroyed-before-july'). Either marketSlug+outcome OR tokenID must be provided
expirationMinutesNoExpiration time in minutes (only for GTD orders)

TDQS

C2.9/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations; description only states action and order types. Does not disclose that limit orders may not fill, order book behavior, or any side effects. Lacks depth.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Extremely concise single sentence with no filler. Every word is necessary.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With 9 parameters, no output schema, and no annotations, the description is too sparse. Missing success/error behavior, required combinations (marketSlug+outcome vs tokenID), and order lifecycle details.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with descriptions for all 9 parameters. Description adds no extra meaning beyond schema, baseline 3 appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states 'Place a limit order' with order types GTC/GTD, distinguishing from placeMarketOrder. However, no explicit differentiation from siblings.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use vs placeMarketOrder, no prerequisites or context provided. Agent must infer from name alone.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

placeMarketOrderB

Place a market order (Fill or Kill / Fill and Kill)

ParametersJSON Schema
NameRequiredDescriptionDefault
sideYesOrder side - BUY or SELL
amountYesAmount in USD to trade
outcomeNoMarket outcome to bet on - YES or NO (required if using marketSlug)
tokenIDNoDirect token ID for the market outcome (alternative to marketSlug+outcome)
tickSizeNoTick size for the market (auto-detected if using marketSlug)
orderTypeYesOrder type - FOK (Fill or Kill) or FAK (Fill and Kill)
marketSlugNoMarket slug from the URL (e.g., 'fordow-nuclear-facility-destroyed-before-july'). Either marketSlug+outcome OR tokenID must be provided

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must disclose behavior. It mentions FOK/FAK but doesn't explain partial fills, execution guarantees, fees, or required permissions. Minimal transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

One concise sentence with no unnecessary words. Could be improved by front-loading critical info but adequate.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Seven parameters, no output schema, no annotations. The description lacks return value info, error handling, prerequisites (e.g., portfolio balance), and edge cases. Incomplete for a trading tool.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description adds no additional meaning beyond the schema; it doesn't clarify the relationship between marketSlug+outcome and tokenID.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action 'Place' and the resource 'market order', and specifies order types (FOK/FAK), distinguishing it from sibling tools like placeLimitOrder.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus placeLimitOrder, nor any conditions for using FOK vs FAK. The agent receives no usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 6 tool updatesv1.0.0
    • First observedgetAllMarkets
    • First observedgetMarketDetails
    • First observedgetOrder
    • First observedgetPortfolio
    • First observedplaceLimitOrder
    • First observedplaceMarketOrder

TDQS

A3.7/5.0

Scored across 6 tools

Disambiguation5/5

Each tool addresses a distinct function: market listing, market details, order details, portfolio overview, and two order types with clear differences. No overlaps.

Naming Consistency5/5

All tools follow a consistent verbNoun camelCase pattern (getAllMarkets, getMarketDetails, getOrder, getPortfolio, placeLimitOrder, placeMarketOrder).

Tool Count5/5

Six tools cover the essential operations for a prediction market server—browsing, querying, portfolio, and trading—without being excessive or insufficient.

Completeness4/5

Core functionalities are present, but missing order cancellation and trade history, which are common in trading APIs. Minor gap.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI assistants to query Polymarket prediction markets, accessing real-time odds, market data, price history, order books, and trending markets across categories like politics, crypto, and sports through natural language.
    17 npm
    5
    MIT
  • F
    license
    Not graded
    quality
    D
    maintenance
    Enables interaction with Polymarket prediction markets through read-only access to market data, events, orderbooks, and user positions, plus authenticated trading capabilities for creating and managing orders.
    1
    -
  • A
    license
    A
    quality
    C
    maintenance
    Enables AI agents to discover and analyze prediction markets, execute trades, and manage positions on Polymarket via the Model Context Protocol.
    7
    51 npm
    20
    MIT