---
title: "AI Agent Integrations"
description: "Connect Horizon to AI agents - trade prediction markets through natural language in Claude Code, Cursor, Claude Desktop, WhatsApp, Telegram, and more."
icon: "plug"
---

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, 181 tools)
    +---> horizon.mcp_fund   (MCP fund server, 30 tools)
    +---> OpenClaw skill     (WhatsApp/Telegram bots)
```

## Available Tools

Key tools available across integrations:

| 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 |
| `cancel_market_orders` | Cancel all orders for a specific market |
| `activate_kill_switch` | Emergency stop - cancels all orders |
| `deactivate_kill_switch` | Resume trading |
| `get_feed_snapshot` | Price/bid/ask for a named feed |
| `list_all_feeds` | All feed snapshots |
| `check_feed_health` | Feed staleness and health report |
| `get_feed_metrics` | Connection metrics for a single feed |
| `get_all_feed_metrics` | Connection metrics for all feeds |
| `discover_markets` | Search Polymarket or Kalshi for markets |
| `discover_events` | Multi-outcome events on Polymarket |
| `top_markets` | Highest-volume active markets |
| `kelly_sizing` | Compute Kelly-optimal position size |
| `check_parity` | YES/NO price parity check |
| `add_stop_loss` | Add a stop-loss contingent order |
| `add_take_profit` | Add a take-profit contingent order |
| `list_contingent_orders` | List pending SL/TP orders |
| `get_wallet_trades` | Trade history for a Polymarket wallet |
| `get_market_trades` | Recent trades for a market |
| `get_wallet_positions` | Open positions for a wallet |
| `get_wallet_value` | Total USD value of wallet positions |
| `get_wallet_profile` | Public profile for a wallet |
| `get_top_holders` | Largest position holders in a market |
| `analyze_market_flow` | Buy/sell flow analytics for a market |
| `simulate_portfolio` | Monte Carlo simulation on current positions |
| `execute_arbitrage` | Atomic cross-exchange arbitrage trade |
| `hedge_analysis` | Hedge ratio, effectiveness, basis risk between spot and hedge |
| `hedge_scenario_analysis` | P&L under various spot moves for a hedged position |
| `multi_ticker_hedge` | Optimal multi-ticker hedge weights |
| `hedge_cost_summary` | Hedge trading cost summary |
| `horizon_setup` | Create account and generate SDK key |
| `horizon_login` | Login and generate new SDK key |
| `horizon_key_status` | Check credential configuration status |

## Quick Setup

<Steps>
  <Step title="Install with MCP support">
    ```bash
    pip install horizon-sdk[mcp]
    # or
    uv pip install horizon-sdk[mcp]
    ```
  </Step>
  <Step title="Set your API key">
    ```bash
    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 `horizon_setup` / `horizon_login`) |
