Skip to main content
Glama
DzimaSh

Polymarket MCP Bot Analyst

by DzimaSh

šŸ¤– Polymarket MCP Bot Analyst

MCP server for analyzing successful trading bots on Polymarket — discover top traders, classify their strategies with AI, and detect bots on the world's largest prediction market.

TypeScript MCP Node.js CI Release


šŸ“‹ Table of Contents


Related MCP server: polymarket-mcp

Overview

This project implements a Model Context Protocol (MCP) server that exposes three powerful tools for analyzing trading activity on Polymarket. It combines real-time leaderboard data from Polymarket's Data API with LLM-powered strategy classification via OpenAI.

Key Features

  • šŸ† Top Trader Discovery — Fetch leaderboard rankings by timeframe

  • 🧠 AI Strategy Analysis — Classify strategies (arbitrage, market-making, etc.) using GPT-4o-mini

  • šŸ¤– Bot Detection — Heuristic + LLM-based identification of automated traders

  • šŸ“Š Batch Reporting — Concurrent analysis of multiple profiles

  • šŸ”„ Resilient API Layer — Exponential backoff, rate-limit handling (429 + Retry-After), graceful fallbacks


graph TD
    subgraph Client ["Client Layer"]
        MCP_Client["MCP Client (e.g., Claude Desktop)"]
    end

    subgraph Server ["MCP Server Layer"]
        index["index.ts (McpServer)"]
        Validation["Zod Validation"]
    end

    subgraph Tools ["Tool Handlers"]
        Traders["traders.ts (find_top_traders)"]
        Analysis["analysis.ts (analyze_trader_strategy)"]
        Reports["reports.ts (generate_batch_report)"]
    end

    subgraph Services ["External Services & Utils"]
        PAPI["api/polymarket.ts (Polymarket Data API)"]
        LLM["utils/llm.ts (OpenAI GPT-4o-mini)"]
    end

    MCP_Client -- "stdio (JSON-RPC)" --> index
    index --> Validation
    Validation --> Traders
    Validation --> Analysis
    Validation --> Reports

    Traders --> PAPI
    Analysis --> PAPI
    Analysis --> LLM
    Reports --> Analysis
    Reports --> PAPI

    style Client fill:#f9f,stroke:#333,stroke-width:2px
    style Server fill:#bbf,stroke:#333,stroke-width:2px
    style Tools fill:#dfd,stroke:#333,stroke-width:2px
    style Services fill:#ffd,stroke:#333,stroke-width:2px

Tool Execution Flow

sequenceDiagram
    participant C as MCP Client
    participant S as MCP Server
    participant T as Tool Handler
    participant P as Polymarket API
    participant L as OpenAI LLM

    C->>S: Call "analyze_trader_strategy"
    S->>S: Validate Input (Zod)
    S->>T: handleAnalyzeStrategy(profile_id)
    T->>P: Fetch Profile Data & PnL
    P-->>T: User Data
    T->>P: Fetch Trade History
    P-->>T: Trade History
    T->>L: Classify strategy (history)
    L-->>T: strategy_analysis (JSON)
    T-->>S: strategy_result
    S-->>C: Tool Response (JSON)

Tools

1. find_top_traders

Fetch top-performing traders from the Polymarket leaderboard with bot detection.

Parameter

Type

Description

limit

integer

Number of traders (1–50)

timeframe

string

"7d", "30d", or "all_time"

Output: Array<{ profile_id, pnl, is_bot }>

2. analyze_trader_strategy

Deep-dive analysis of a single trader using trade history + LLM classification.

Parameter

Type

Description

profile_id

string

Wallet address (0x…) or username (@name)

Output: { strategy_description, risk_level, risk_justification, success_score, is_bot }

3. generate_batch_report

Concurrent analysis of multiple profiles with error-resilient execution.

Parameter

Type

Description

profile_ids

string[]

Array of profile IDs (1–50)

Output: Array<{ profile_id, pnl, strategy_description, risk_level, risk_justification, success_score, is_bot }>


Getting Started

Prerequisites

  • Node.js ≄ 22

  • npm ≄ 10

  • OpenAI API key (for strategy analysis)

Installation

# Clone the repository
git clone <your-repo-url>
cd polymarket-mcp-bot-analyst

# Install dependencies
npm install

# Configure environment
cp .env.example .env
# Edit .env and add your OPENAI_API_KEY

Build & Run

# Build TypeScript
npm run build

# Start the MCP server (stdio transport)
npm start

# Or run directly with tsx (development)
npm run dev

Connect to Claude Desktop

Add this server to your Claude Desktop configuration:

macOS

Edit ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "polymarket-bot-analyst": {
      "command": "node",
      "args": ["/absolute/path/to/polymarket-mcp-bot-analyst/dist/index.js"],
      "env": {
        "OPENAI_API_KEY": "sk-..."
      }
    }
  }
}

Windows

Edit %APPDATA%\Claude\claude_desktop_config.json:

{
  "mcpServers": {
    "polymarket-bot-analyst": {
      "command": "node",
      "args": ["C:\\path\\to\\polymarket-mcp-bot-analyst\\dist\\index.js"],
      "env": {
        "OPENAI_API_KEY": "sk-..."
      }
    }
  }
}

After saving, restart Claude Desktop. The three tools will appear in the tools menu (šŸ”Ø icon).


Run the Test Suite

The test runner executes all three tools against the live Polymarket API and generates the required JSON artifacts:

npm run test:run

This produces:

File

Description

test_run.json

Full execution log with data for 3+ traders

performance_report.json

Latency metrics for each endpoint

my_report.json

Architectural description of each endpoint


Project Structure

polymarket-mcp-bot-analyst/
ā”œā”€ā”€ src/
│   ā”œā”€ā”€ index.ts              # MCP server entry point
│   ā”œā”€ā”€ types.ts              # Shared interfaces & config
│   ā”œā”€ā”€ api/
│   │   └── polymarket.ts     # Polymarket Data API wrapper
│   ā”œā”€ā”€ tools/
│   │   ā”œā”€ā”€ traders.ts        # find_top_traders handler
│   │   ā”œā”€ā”€ analysis.ts       # analyze_trader_strategy handler
│   │   └── reports.ts        # generate_batch_report handler
│   ā”œā”€ā”€ utils/
│   │   └── llm.ts            # OpenAI LLM integration
│   └── test-run.ts           # Artifact generator script
ā”œā”€ā”€ test_run.json             # Generated test run log
ā”œā”€ā”€ performance_report.json   # Generated latency metrics
ā”œā”€ā”€ my_report.json            # Generated architecture report
ā”œā”€ā”€ package.json
ā”œā”€ā”€ tsconfig.json
ā”œā”€ā”€ .env.example
└── .gitignore

Configuration

Environment Variable

Required

Description

OPENAI_API_KEY

Yes

OpenAI API key for GPT-4o-mini

Internal Constants (in src/types.ts)

Constant

Default

Description

POLYMARKET_API_BASE

https://data-api.polymarket.com

API base URL

REQUEST_TIMEOUT_MS

15000

HTTP request timeout

MAX_RETRIES

3

Max retry attempts per request

RETRY_BASE_DELAY_MS

1000

Base delay for exponential backoff

BOT_TRADE_THRESHOLD

200

Min trades to flag as bot

BOT_TRADES_PER_HOUR_THRESHOLD

10

Min trades/hour for bot flag


License

MIT

Available Tools

3 tools
analyze_trader_strategyA

Analyze a trader's strategy using trade history and LLM classification. Returns strategy type, risk level, success score, and bot detection.

ParametersJSON Schema
NameRequiredDescriptionDefault
profile_idYesPolymarket profile ID — wallet address (0x…) or username (@name).

TDQS

A3.8/5.0
Behavior3/5

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

With no annotations provided, the description carries the burden of disclosing behavior. It mentions the methodology (trade history and LLM classification) and the return fields, which adds transparency. However, it does not disclose potential limitations (e.g., data freshness, latency, reliance on profile existence) or safety characteristics beyond the fact that it is an analysis function.

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, well-structured sentence that front-loads the core action and immediately specifies what the tool returns. Every word earns its place; there is no redundant phrasing.

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 the tool's low complexity (one parameter) and the absence of an output schema, the description provides adequate context by listing the return categories (strategy type, risk level, success score, bot detection). It does not detail output structures or error scenarios, but for a simple analyzer this is reasonably complete.

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?

The input schema already provides a thorough description of the single parameter (profile_id) including format and examples. The description adds no additional parameter semantics, so the baseline score of 3 for high schema coverage applies.

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 tool's function with a specific verb ('Analyze') and resource ('a trader's strategy'), and distinguishes it from siblings by focusing on individual trader analysis rather than discovery (find_top_traders) or batch reporting (generate_batch_report). It also enumerates the key outputs, leaving no ambiguity about the tool's scope.

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?

The description implies use when a specific trader's strategy needs evaluation, but it does not explicitly state when to prefer this tool over alternatives or when not to use it. There is no mention of exclusions or comparisons with sibling tools, so the guidance is only implicit.

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

find_top_tradersA

Fetch top traders from the Polymarket leaderboard. Detects bots based on trade frequency and volume.

ParametersJSON Schema
NameRequiredDescriptionDefault
limitYesNumber of traders to return (1–50).
timeframeYesLeaderboard timeframe: "7d", "30d", or "all_time".

TDQS

A4/5.0
Behavior3/5

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

No annotations are provided, so the description carries the burden. It discloses the bot-detection behavior based on trade frequency and volume, which is useful. However, it does not detail return format, whether bots are filtered or flagged, or other operational aspects.

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 two sentences long with no unnecessary words. The primary action is front-loaded, and the second sentence adds valuable behavioral context about bot detection.

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?

For a simple tool with two well-documented parameters and no output schema, the description is reasonably complete. It explains the main purpose and a key behavior, though it could clarify what data is returned and how bot detection affects the output.

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 both parameters clearly documented in the schema. The description does not add additional parameter-specific meaning beyond what the schema already provides, so the baseline 3 is appropriate.

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 tool fetches top traders from the Polymarket leaderboard, with a specific verb and resource. It adds a unique capability (bot detection) that distinguishes it from siblings like analyze_trader_strategy and generate_batch_report.

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 context is clear: use this to obtain leaderboard data. It implies a straightforward use case without explicit alternatives or exclusions, but the sibling tool names are distinct enough that the intended usage is evident.

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

generate_batch_reportA

Concurrently analyze multiple trader profiles and generate a combined report with PnL, risk, score, and bot status.

ParametersJSON Schema
NameRequiredDescriptionDefault
profile_idsYesArray of profile IDs (wallet addresses or usernames).

TDQS

A3.7/5.0
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It adds useful context by noting that analysis happens 'concurrently' and that the result is a 'combined report' with specific metrics. However, it does not explicitly state whether the operation is read-only, the nature of the report structure, or any potential side effects or limitations (e.g., rate limits, failure handling).

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?

A single sentence that is front-loaded with the action ('Concurrently analyze') and resource ('multiple trader profiles'), followed by the output contents. Every word contributes, with no redundancy or filler.

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?

Given the absence of an output schema, the description should clarify what the 'combined report' looks like (e.g., per-profile breakdown vs. aggregated summary) and any edge cases. It lists key fields but leaves structural ambiguity about how results are organized, making it minimally complete but not fully self-sufficient.

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 profile_ids, with a clear description in the schema. The tool description merely echoes 'multiple trader profiles,' adding little beyond the schema's 'Array of profile IDs (wallet addresses or usernames).' Thus the baseline of 3 is appropriate.

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 tool's function: 'Concurrently analyze multiple trader profiles and generate a combined report' with specific output components (PnL, risk, score, bot status). This distinguishes it from sibling tools like analyze_trader_strategy (single profile) and find_top_traders (discovery).

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?

The phrase 'multiple trader profiles' implies a batch use case, but it does not explicitly contrast with analyzing profiles individually via analyze_trader_strategy, nor does it state conditions for when this tool is preferred. Usage context is only implied, not explicitly guided.

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. 3 tool updatesv1.0.0
    • First observedanalyze_trader_strategy
    • First observedfind_top_traders
    • First observedgenerate_batch_report

TDQS

A4.2/5.0

Scored across 3 tools

Disambiguation5/5

Each tool has a clearly distinct purpose: finding top traders, analyzing a single trader's strategy, and generating batch reports. No overlap in functionality.

Naming Consistency5/5

All tool names follow the verb_noun pattern (find_top_traders, analyze_trader_strategy, generate_batch_report), providing a predictable and consistent naming convention.

Tool Count5/5

Three tools are perfectly scoped for this niche domain of trader analysis and bot detection. Each tool earns its place, and the count is neither too thin nor excessive.

Completeness5/5

The tool set covers the full workflow: discovering traders via the leaderboard, deep-diving into individual strategies, and scaling to batch analysis. No critical gaps or dead ends.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    An MCP server that gives AI agents direct access to Polymarket Crypto prediction markets, enriched with live spot prices. Discover markets, analyze order books, paper trade strategies, track activity, and execute live trades — all through natural language.
    1
    AGPL 3.0
  • A
    license
    Not graded
    quality
    B
    maintenance
    An MCP server and Python toolkit that provides AI agents with real-time tools for Polymarket prediction markets, including liquidity scanning, arbitrage detection, and slippage estimation. It also offers advanced wallet intelligence, portfolio risk calculation, and probabilistic reasoning to enhance market analysis and strategy.
    11 PyPI
    1
    MIT
  • A
    license
    B
    quality
    C
    maintenance
    MCP server to query Polymarket prediction market data via The Graph subgraphs and REST APIs, enabling AI agents to search markets, get live prices, order books, on-chain analytics, and trader profiles.
    32
    77 npm
    MIT