> ## Documentation Index
> Fetch the complete documentation index at: https://mathematicalcompany.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Agent Integrations

> Connect Horizon to AI agents - trade prediction markets, equities, options, and crypto through natural language in Claude Code, Cursor, Claude Desktop, WhatsApp, Telegram, and more.

Horizon SDK exposes its full trading engine via three integration paths:

<CardGroup cols={3}>
  <Card title="CLI" icon="terminal" href="/integrations/cli">
    Full-featured command-line interface. Discover markets, trade, analyze wallets, and manage funds from the terminal. Supports `--json` for scripting.
  </Card>

  <Card title="MCP Server" icon="server" href="/integrations/mcp-server">
    Standard Model Context Protocol server. Works with Claude Code, Cursor, Windsurf, VS Code, and Claude Desktop.
  </Card>

  <Card title="OpenClaw Skill" icon="robot" href="/integrations/openclaw">
    Plugin for the OpenClaw framework. Works with WhatsApp, Telegram, Discord, and Slack bots. Install from [ClawHub](https://clawhub.ai): `clawhub install horizon-trader`
  </Card>
</CardGroup>

## How It Works

All three integrations share a thin tools layer (`horizon.tools`) that wraps the Engine API. The CLI, MCP server, and OpenClaw skill are interface adapters that delegate to shared tool functions, which in turn call the Horizon Engine (Rust core via PyO3) for risk, orders, feeds, and exchange connectivity.

```
horizon.tools (shared business logic, 100+ functions)
    |
    +---> horizon.cli        (Click CLI, 40+ commands)
    +---> horizon.mcp_server (MCP server, 25 tools with 241 capabilities)
    +---> horizon.mcp_fund   (MCP fund server, 30 tools)
    +---> OpenClaw skill     (WhatsApp/Telegram bots)
```

## Available MCP Tools

The MCP server exposes 14 individual tools and 12 compound tools (action-dispatch):

**Individual tools** — most-used trading operations:

| Tool                   | Description                                           |
| ---------------------- | ----------------------------------------------------- |
| `engine_status`        | PnL, open orders, positions, kill switch, uptime      |
| `list_positions`       | All open positions with entry price and PnL           |
| `list_open_orders`     | Open orders, optionally filtered by market            |
| `list_recent_fills`    | Recent trade fills                                    |
| `submit_order`         | Place a limit order (buy/sell at a probability price) |
| `cancel_order`         | Cancel one order by ID                                |
| `cancel_all_orders`    | Cancel everything                                     |
| `discover_markets`     | Search Polymarket or Kalshi for markets               |
| `get_market_detail`    | Full market detail (prices, orderbook, holders)       |
| `top_markets`          | Highest-volume active markets                         |
| `kelly_sizing`         | Compute Kelly-optimal position size                   |
| `get_feed_snapshot`    | Price/bid/ask for a named feed                        |
| `activate_kill_switch` | Emergency stop - cancels all orders                   |
| `portfolio_metrics`    | Portfolio value, exposure, diversification            |

**Compound tools** — group related capabilities via `action` parameter:

| Tool               | Actions | Description                                                    |
| ------------------ | ------- | -------------------------------------------------------------- |
| `feed`             | 7       | Feed management, health, parity checks                         |
| `order_management` | 5       | Stop-loss, take-profit, cancel by market, kill switch off      |
| `wallet`           | 11      | Wallet trades, positions, flow, profiling, signals             |
| `analytics`        | 84      | Stats, AFML, microstructure, hedging, pricing, bootstrap       |
| `scanning`         | 11      | Oracle, LLM, whale, sniper scans, arbitrage, stealth execution |
| `unusual_whales`   | 36      | Options flow, Congress trades, Greeks, short interest          |
| `market_data`      | 24      | Polygon.io: OHLCV, snapshots, indicators, options chains       |
| `cloud`            | 12      | Cloud deploy, monitor, credentials                             |
| `marketplace`      | 18      | Browse, publish, subscribe, purchase strategies                |
| `fund`             | 16      | Multi-strategy fund management                                 |
| `account`          | 3       | Account setup, login, key status                               |

## Quick Setup

<Steps>
  <Step title="Install with MCP support">
    ```bash theme={null}
    pip install horizon-sdk[mcp]
    # or
    uv pip install horizon-sdk[mcp]
    ```
  </Step>

  <Step title="Set your API key">
    ```bash theme={null}
    export HORIZON_API_KEY="your-key"
    ```
  </Step>

  <Step title="Choose your interface">
    Pick a setup guide:

    * [CLI](/integrations/cli) - terminal, scripting, `uvx`
    * [Claude Code](/integrations/claude-code)
    * [Cursor / Windsurf / VS Code](/integrations/cursor)
    * [Claude Desktop](/integrations/claude-desktop)
    * [OpenClaw (WhatsApp/Telegram)](/integrations/openclaw)
  </Step>
</Steps>

## Environment Variables

The MCP server and OpenClaw skill read configuration from environment variables:

| Variable                    | Required       | Default | Description                                                                                             |
| --------------------------- | -------------- | ------- | ------------------------------------------------------------------------------------------------------- |
| `HORIZON_API_KEY`           | Yes            | -       | SDK authentication key                                                                                  |
| `HORIZON_EXCHANGE`          | No             | `paper` | `paper`, `polymarket`, or `kalshi`                                                                      |
| `HORIZON_DB`                | No             | -       | SQLite path for persistence                                                                             |
| `POLYMARKET_API_KEY`        | For Polymarket | -       | Polymarket CLOB API key                                                                                 |
| `POLYMARKET_API_SECRET`     | For Polymarket | -       | Polymarket CLOB API secret                                                                              |
| `POLYMARKET_API_PASSPHRASE` | For Polymarket | -       | Polymarket CLOB passphrase                                                                              |
| `POLYMARKET_PRIVATE_KEY`    | For Polymarket | -       | Ethereum private key                                                                                    |
| `KALSHI_API_KEY`            | For Kalshi     | -       | Kalshi API key                                                                                          |
| `KALSHI_EMAIL`              | For Kalshi     | -       | Kalshi account email                                                                                    |
| `KALSHI_PASSWORD`           | For Kalshi     | -       | Kalshi account password                                                                                 |
| `HORIZON_PASSWORD`          | No             | -       | Password for programmatic account setup (used by `account(action="setup")` / `account(action="login")`) |
