Skip to main content
Glama
Polmexbot MCP Server

Polmexbot MCP Server

Official
by PolmexBot
README.md
# Polmexbot MCP Server

[![CI](https://github.com/PolmexBot/polmexbot-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/PolmexBot/polmexbot-mcp/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)
[![Node.js >= 20](https://img.shields.io/badge/node-%3E%3D20-brightgreen.svg)](https://nodejs.org/)

Official **Model Context Protocol (MCP)** server, no-wallet in-memory sandbox, and reference AI agents for **[Polmexbot](https://www.polmexbot.xyz)** (also compatible with **[polmexbot.pro](https://www.polmexbot.pro)**) — an automated Polymarket trading engine for 5-minute crypto up/down rounds (**BTC, ETH, SOL, XRP, DOGE, BNB**).

Polmexbot exposes structured tools for wallet readiness, configuration preview & validation, engine start/stop, positions, trades, and live logs. It controls Polmexbot's existing strategy engine (`constellation`, `aistrat`, `aces`, `custom`) and does **not** expose arbitrary buy/sell or market-making order placement.

---

## Quickstart (No Wallet Required — Sandbox)

Run directly with `npx` (Node.js 20+ required) — zero setup, zero network calls, 100 simulated `pUSD`:

### Claude Desktop / Cursor / Claude Code / Windsurf

Add this to your MCP client config (`claude_desktop_config.json`, `.cursor/mcp.json`, or `.mcp.json`):

```json
{
  "mcpServers": {
    "polmexbot": {
      "command": "npx",
      "args": ["-y", "github:PolmexBot/polmexbot-mcp"],
      "env": {
        "POLMEXBOT_SANDBOX": "true"
      }
    }
  }
}
```

Or install globally from GitHub:

```bash
npm install -g github:PolmexBot/polmexbot-mcp
POLMEXBOT_SANDBOX=true polmexbot-mcp
```

> **Official site endpoints:** Default API base URL is `https://www.polmexbot.xyz`. To target `polmexbot.pro`, set `"POLMEXBOT_BASE_URL": "https://www.polmexbot.pro"`. Legacy `POLMEXBOTXYZ_*` and `POLMEXBOTPRO_*` environment prefixes are also supported automatically.

> **Region note for live API calls:** Live Polmexbot API endpoints follow Polymarket regional restrictions (US IPs receive HTTP `451`). Sandbox mode works anywhere with no network calls; for live trading, run your MCP client / agent server outside the US (e.g. EU or Asia).

---

## Operating Modes

### 1. Live Read-Only Mode (Default)

A human connects their account via [Polmexbot Settings](https://www.polmexbot.xyz/settings) (or [polmexbot.pro/settings](https://www.polmexbot.pro/settings)) and passes only the bearer token:

```json
{
  "mcpServers": {
    "polmexbot": {
      "command": "npx",
      "args": ["-y", "github:PolmexBot/polmexbot-mcp"],
      "env": {
        "POLMEXBOT_BASE_URL": "https://www.polmexbot.xyz",
        "POLMEXBOT_TOKEN": "your-account-bearer-token"
      }
    }
  }
}
```

Connecting alone never starts trading. Only read-only and configuration-preview tools are registered.

### 2. Supervised Approval-Gated Controls

Require an explicit human approval token + immutable `previewHash` before applying configuration changes or starting the engine:

```json
{
  "mcpServers": {
    "polmexbot": {
      "command": "npx",
      "args": ["-y", "github:PolmexBot/polmexbot-mcp"],
      "env": {
        "POLMEXBOT_BASE_URL": "https://www.polmexbot.xyz",
        "POLMEXBOT_TOKEN": "your-account-bearer-token",
        "POLMEXBOT_ENABLE_CONTROLS": "true",
        "POLMEXBOT_APPROVAL_TOKEN": "owner-created-approval-secret"
      }
    }
  }
}
```

1. Call `preview_config` and show the owner the exact diff.
2. Call `apply_config` with the unchanged `previewHash` and owner `approvalToken`.
3. Call `preview_config` with `{}` and then `start_bot` with the fresh `previewHash` + `approvalToken` (requires a passing `check_readiness`).
4. Call `stop_bot` at any time without an approval token (stops new activity; does not sell open positions).

### 3. Autonomous Mode (Dedicated Wallet Key)

For trusted autonomous agents managing a dedicated, limited-funds Polygon wallet:

```json
{
  "mcpServers": {
    "polmexbot": {
      "command": "npx",
      "args": ["-y", "github:PolmexBot/polmexbot-mcp"],
      "env": {
        "POLMEXBOT_BASE_URL": "https://www.polmexbot.xyz",
        "POLMEXBOT_AUTONOMOUS": "true"
      }
    }
  }
}
```

1. Call `connect_wallet` with `privateKey` (optional `developerAddress` is derived automatically for Polymarket deposit/proxy wallets). Neither key nor bearer token is returned in tool results.
2. Call `check_readiness` and `preview_config`.
3. Call `apply_config` with the unchanged `previewHash`, then an empty `preview_config` → `start_bot`.
4. Confirm live execution via `get_bot_state`, `get_positions`, `get_trades`, and `get_logs`.

### 4. Direct EOA Mode (No Polymarket Website Required)

If a dedicated EOA already holds **pUSD** (and a little **POL** for approval gas) on Polygon:

1. Call `connect_wallet({ privateKey, walletMode: "eoa" })` (omit `developerAddress`).
2. Call `prepare_eoa_wallet({ approve: false })` to inspect pUSD, POL, Exchange V2 allowance, cap, and estimated gas without broadcasting.
3. If allowance is required, call `prepare_eoa_wallet({ approve: true })` to broadcast a capped pUSD approval.
4. Proceed with `check_readiness` → `preview_config` → `apply_config` → empty `preview_config` → `start_bot`.

---

## Available MCP Tools

| Tool | Mode | Purpose |
| --- | --- | --- |
| `get_server_info` | Read-only | Returns integration mode, active base URL, mirrors, and doc links (no auth). |
| `get_public_prices` | Read-only | Public BTC, ETH, SOL, XRP, and BNB price snapshot (no auth). |
| `get_account` | Read-only | Authenticated account, strategy config, wallet-link metadata, stats (keys redacted). |
| `get_balance` | Read-only | pUSD, USDC.e, POL, open-position value, live bankroll, warnings, restrictions. |
| `get_bot_state` | Read-only | Requested & live engine state, freshness, positions, recent trades, notices. |
| `get_positions` | Read-only | Current open positions plus engine freshness flags. |
| `get_trades` | Read-only | Up to 200 persisted resolved trades and aggregate statistics. |
| `get_logs` | Read-only | Engine activity, skips, errors, and trade-result logs. |
| `check_readiness` | Read-only | Verifies deployment, key/wallet pairing, collateral, and readiness (no tx). |
| `preview_config` | Read-only | Validates a partial config patch and returns diff, warnings, and `previewHash`. |
| `connect_wallet` | Autonomous | Connects a dedicated wallet key (Polymarket account or direct EOA) in memory. |
| `prepare_eoa_wallet` | Control | Inspects or sends a capped pUSD Exchange V2 approval in direct EOA mode. |
| `apply_config` | Control | Saves validated configuration after matching `previewHash` (+ approval if supervised). |
| `start_bot` | Control | Starts strategy execution after fresh empty preview + readiness pass. |
| `stop_bot` | Control | Stops new engine activity without approval token (does not liquidate positions). |

---

## Reference Agents & Local Development

```bash
git clone https://github.com/PolmexBot/polmexbot-mcp.git
cd polmexbot-mcp
npm install
npm test

# Sandbox reference agents (zero network calls)
node examples/read-only-monitor.mjs --sandbox
node examples/supervised-agent.mjs --sandbox
node examples/supervised-agent.mjs --sandbox --approve
node examples/autonomous-agent.mjs --sandbox
node examples/autonomous-agent.mjs --sandbox --eoa
node examples/alert-agent.mjs --sandbox
```

---

## Machine Discovery & Official Links

| Resource | polmexbot.xyz | polmexbot.pro |
| --- | --- | --- |
| MCP Guide | https://www.polmexbot.xyz/agents/mcp | https://www.polmexbot.pro/agents/mcp |
| REST API Guide | https://www.polmexbot.xyz/agents | https://www.polmexbot.pro/agents |
| OpenAPI 3.1 | https://www.polmexbot.xyz/openapi.json | https://www.polmexbot.pro/openapi.json |
| `llms.txt` | https://www.polmexbot.xyz/llms.txt | https://www.polmexbot.pro/llms.txt |
| Markdown Guide | https://www.polmexbot.xyz/agents.md | https://www.polmexbot.pro/agents.md |
| OAuth Metadata | https://www.polmexbot.xyz/.well-known/oauth-protected-resource | https://www.polmexbot.pro/.well-known/oauth-protected-resource |

## Security

- Always use a **dedicated, limited-funds wallet** for automated trading.
- Never place private keys or bearer tokens in prompts, command-line arguments, or source control.
- Protect MCP client logs, as some clients record tool call arguments.
- Never use Hardhat/Anvil/example test keys in live mode.
- Stopping the bot disables new trades; it does **not** liquidate existing open positions.

## License

[MIT](./LICENSE)

TDQS

A3.7/5.0

Scored across 14 tools

Disambiguation4/5

Most tools have clear distinct purposes, but the read-side cluster (get_account, get_balance, get_bot_state, get_trades, get_positions) overlaps heavily, since several return positions, trades, and statistics from different sources. The descriptions do explain the difference (persisted trades vs live engine state vs staleness caveat), so an agent can reason it out, but it takes careful reading.

Naming Consistency5/5

All 14 tools use snake_case verb-first names (get_*, check_*, start_*, stop_*, preview_*, prepare_*, apply_*), forming a predictable pattern. There are no mixed conventions or cryptic abbreviations beyond the standard 'eoa' qualifier.

Tool Count5/5

At 14 tools the surface is well within the ideal range and each tool maps to a real operation (read state, validate config, mutate config, lifecycle control, wallet prep). Nothing appears to be filler, and the read tools, while numerous, correspond to genuinely different data sources.

Completeness3/5

The control loop is covered (preview -> apply -> readiness -> start/stop), but there is no path to exit or manage existing positions, no order cancellation or inspection, and stop_bot explicitly does not sell. The absence of any sell/close tool is a deliberate safety design, yet it leaves a notable dead end for an agent asked to unwind exposure.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues