Skip to content
Back to search

ai-polymarket-agent

Enable Claude, ChatGPT, and other AI agents to analyze markets, fetch real-time odds, and execute trades on Polymarket using the Model Context Protocol (MCP).

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/kaktusesquire6rmu--ai-polymarket-agent/badge.svg)](/listings/kaktusesquire6rmu--ai-polymarket-agent)

HTML

<a href="/listings/kaktusesquire6rmu--ai-polymarket-agent"><img src="/api/listings/kaktusesquire6rmu--ai-polymarket-agent/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import {
  CallToolRequestSchema,
  ListToolsRequestSchema,
} from "@modelcontextprotocol/sdk/types.js";
import axios from "axios";

const server = new Server(
  {
    name: "polymarket-mcp-server",
    version: "1.0.0",
  },
  {
    capabilities: {
      tools: {},
    },
  }
 );

/**
 * Список доступных инструментов для ИИ
 */
server.setRequestHandler(ListToolsRequestSchema, async () => {
  return {
    tools: [
      {
        name: "search_markets",
        description: "Search for active prediction markets on Polymarket by keyword",
        inputSchema: {
          type: "object",
          properties: {
            query: { type: "string", description: "Keyword to search (e.g., 'Bitcoin', 'Election')" },
          },
          required: ["query"],
        },
      },
      {
        name: "get_market_odds",
        description: "Get real-time odds and order book data for a specific market ID",
        inputSchema: {
          type: "object",
          properties: {
            conditionId: { type: "string", description: "The unique condition ID of the market" },
          },
          required: ["conditionId"],
        },
      },
    ],
  };
});

/**
 * Логика выполнения инструментов
 */
server.setRequestHandler(CallToolRequestSchema, async (request) => {
  const { name, arguments: args } = request.params;

  try {
    if (name === "search_markets") {
      const query = args?.query as string;
      const response = await axios.get(`${POLYMARKET_API_BASE}/markets?active=true`);
      const markets = response.data
        .filter((m: any) => m.question.toLowerCase().includes(query.toLowerCase()))
        .slice(0, 5);

      return {
        content: [{ type: "text", text: JSON.stringify(markets, null, 2) }],
      };
    }

    if (name === "get_market_odds") {
      const conditionId = args?.conditionId as string;
      const response = await axios.get(`${POLYMARKET_API_BASE}/book?token_id=${conditionId}`);

      return {
        content: [{ type: "text", text: JSON.stringify(response.data, null, 2) }],
      };
    }

    throw new Error(`Tool not found: ${name}`);
  } catch (error: any) {
    return {
      content: [{ type: "text", text: `Error: ${error.message}` }],
      isError: true,
    };
  }
});

/**
 * Запуск сервера через стандартный ввод/вывод (Stdio)
 */
async function main() {
  const transport = new StdioServerTransport();
  await server.connect(transport);
  console.error("Polymarket MCP Server running on stdio");
}

main().catch((error) => {
  console.error("Fatal error in main():", error);
  process.exit(1);
});

---

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 225 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # 🤖 Polymarket MCP Server: Trade Prediction Markets with AI Agents
  2. Connect Polymarket to your AI. The official-like MCP implementation for real-time prediction market analysis, automated odds tracking, and AI-powered trading insights.
  3. # 📊 Dashboard
  4. <img width="1536" height="1024" alt="polymarket_mcp_banner" src="https://github.com/user-attachments/assets/95907a83-b0f9-4e11-b937-871420f33b17" />
  5. <img width="1248" height="832" alt="polymarket_mcp_dashboard_v2" src="https://github.com/user-attachments/assets/cd654773-60f1-4b54-b4f1-0cd32b8438ed" />
  6. # 🚀 Getting Started
  7. ```bash
  8. import { Server } from "@modelcontextprotocol/sdk/server/index.js";
  9. import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
  10. import {
  11. CallToolRequestSchema,
  12. ListToolsRequestSchema,
  13. } from "@modelcontextprotocol/sdk/types.js";
  14. import axios from "axios";
  15. const server = new Server(
  16. {
  17. name: "polymarket-mcp-server",
  18. version: "1.0.0",
  19. },
  20. {
  21. capabilities: {
  22. tools: {},
  23. },
  24. }
  25. );
  26. /**
  27. * Список доступных инструментов для ИИ
  28. */
  29. server.setRequestHandler(ListToolsRequestSchema, async () => {
  30. return {
  31. tools: [
  32. {
  33. name: "search_markets",
  34. description: "Search for active prediction markets on Polymarket by keyword",
  35. inputSchema: {
  36. type: "object",
  37. properties: {
  38. query: { type: "string", description: "Keyword to search (e.g., 'Bitcoin', 'Election')" },
  39. },
  40. required: ["query"],
  41. },
  42. },
  43. {
  44. name: "get_market_odds",
  45. description: "Get real-time odds and order book data for a specific market ID",
  46. inputSchema: {
  47. type: "object",
  48. properties: {
  49. conditionId: { type: "string", description: "The unique condition ID of the market" },
  50. },
  51. required: ["conditionId"],
  52. },
  53. },
  54. ],
  55. };
  56. });
  57. /**
  58. * Логика выполнения инструментов
  59. */
  60. server.setRequestHandler(CallToolRequestSchema, async (request) => {
  61. const { name, arguments: args } = request.params;
  62. try {
  63. if (name === "search_markets") {
  64. const query = args?.query as string;
  65. const response = await axios.get(`${POLYMARKET_API_BASE}/markets?active=true`);
  66. const markets = response.data
  67. .filter((m: any) => m.question.toLowerCase().includes(query.toLowerCase()))
  68. .slice(0, 5);
  69. return {
  70. content: [{ type: "text", text: JSON.stringify(markets, null, 2) }],
  71. };
  72. }
  73. if (name === "get_market_odds") {
  74. const conditionId = args?.conditionId as string;
  75. const response = await axios.get(`${POLYMARKET_API_BASE}/book?token_id=${conditionId}`);
  76. return {
  77. content: [{ type: "text", text: JSON.stringify(response.data, null, 2) }],
  78. };
  79. }
  80. throw new Error(`Tool not found: ${name}`);
  81. } catch (error: any) {
  82. return {
  83. content: [{ type: "text", text: `Error: ${error.message}` }],
  84. isError: true,
  85. };
  86. }
  87. });
  88. /**
  89. * Запуск сервера через стандартный ввод/вывод (Stdio)
  90. */
  91. async function main() {
  92. const transport = new StdioServerTransport();
  93. await server.connect(transport);
  94. console.error("Polymarket MCP Server running on stdio");
  95. }
  96. main().catch((error) => {
  97. console.error("Fatal error in main():", error);
  98. process.exit(1);
  99. });
  100. ```
  101. ---
  102. # ✨ Features
  103. * get_market_data: Fetch live odds for any Polymarket URL.
  104. * search_markets: Find trending markets by keywords.
  105. * execute_trade: (Optional/Advanced) Place orders via API.
  106. # 🧱 Architecture
  107. ```bash
  108. polymarket-mcp-server-ai-agents/
  109. │
  110. ├── server/
  111. │ ├── agents/
  112. │ ├── strategies/
  113. │ ├── api/
  114. │ ├── data/
  115. │ └── core/
  116. │
  117. ├── scripts/
  118. ├── tests/
  119. ├── docs/
  120. │
  121. ├── .env.example
  122. ├── README.md
  123. ├── package.json / requirements.txt
  124. └── docker-compose.yml
  125. ```
  126. * Agents – AI decision-makers
  127. * Strategies – trading logic
  128. * Data Layer – market + external signals
  129. * API Layer – Polymarket integration
  130. * Core Engine – execution + risk control
  131. # Tech Stack
  132. **Backend:**
  133. * Python
  134. * FastAPI
  135. * Web3.py
  136. **AI Layer:**
  137. * OpenAI / LLMs
  138. * Custom probability models
  139. **Frontend:**
  140. * React / Next.js
  141. * TailwindCSS
  142. * Recharts
  143. **Data Layer:**
  144. * WebSockets (real-time markets)
  145. * PostgreSQL / Redis
  146. Modern trading systems often use **event-driven architectures + real-time streams + AI scoring engines** ([Prolymarket][4])
  147. # Use Cases
  148. Automated prediction market trading
  149. AI-powered crypto speculation
  150. Political and event forecasting
  151. Arbitrage strategies
  152. Sentiment-based trading
  153. ## 🧪 Roadmap
  154. - [ ] 🧱 Basic MCP server
  155. Initial implementation of the MCP (Model Context Protocol) server core, including request handling and modular architecture.
  156. - [ ] 🔗 Polymarket API integration
  157. Connect to Polymarket APIs to fetch real-time market data, prices, and execute trades programmatically.
  158. - [ ] 🤖 AI agent framework
  159. Develop a flexible framework for creating and managing AI trading agents with pluggable strategies.
  160. - [ ] 🧠 Strategy marketplace
  161. Enable users to create, share, and deploy custom trading strategies in a modular marketplace.
  162. - [ ] 📈 Reinforcement learning agents
  163. Implement RL-based agents capable of learning and improving trading strategies over time.
  164. - [ ] 📊 Dashboard UI
  165. Build a web-based interface for monitoring agents, strategies, trades, and performance analytics.
  166. # 🐳 6. Docker
  167. ### Dockerfile
  168. ```dockerfile
  169. FROM python:3.11
  170. WORKDIR /app
  171. COPY . .
  172. RUN pip install -r requirements.txt
  173. CMD ["python", "main.py"]
  174. ```
  175. ![License](https://img.shields.io/badge/license-MIT-blue)
  176. ![Build](https://img.shields.io/github/actions/workflow/status/...)
  177. ![Stars](https://img.shields.io/github/stars/...)
  178. Keywords: polymarket bot, AI trading agent, prediction market automation, crypto AI trading, decentralized trading bots, web3 AI tools

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.