---
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 to AI agents via two integration paths:

<CardGroup cols={2}>
  <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

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

## Available Tools

Every integration exposes the same 32 tools:

| 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 |

## Quick Setup

<Steps>
  <Step title="Install with MCP support">
    ```bash
    pip install horizon-sdk[mcp]
    ```
  </Step>
  <Step title="Set your API key">
    ```bash
    export HORIZON_API_KEY="your-key"
    ```
  </Step>
  <Step title="Choose your client">
    Pick a setup guide:
    - [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 |
