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

# Cursor / Windsurf / VS Code

> Add Horizon as an MCP server in Cursor, Windsurf, or VS Code for AI-assisted trading.

Cursor, Windsurf, and VS Code all support MCP servers. Adding Horizon gives the AI assistant access to your trading engine directly from your editor.

## Cursor

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

  <Step title="Configure">
    Open **Cursor Settings** > **MCP Servers** and add:

    ```json theme={null}
    {
      "horizon": {
        "command": "python",
        "args": ["-m", "horizon.mcp"],
        "env": {
          "HORIZON_API_KEY": "your-key",
          "HORIZON_EXCHANGE": "paper"
        }
      }
    }
    ```

    Or create/edit `.cursor/mcp.json` in your project root:

    ```json theme={null}
    {
      "mcpServers": {
        "horizon": {
          "command": "python",
          "args": ["-m", "horizon.mcp"],
          "env": {
            "HORIZON_API_KEY": "your-key",
            "HORIZON_EXCHANGE": "paper"
          }
        }
      }
    }
    ```
  </Step>

  <Step title="Use">
    In Cursor's AI chat, ask about positions, markets, or orders. The assistant will use Horizon tools automatically.
  </Step>
</Steps>

## Windsurf

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

  <Step title="Configure">
    Create or edit `~/.codeium/windsurf/mcp_config.json`:

    ```json theme={null}
    {
      "mcpServers": {
        "horizon": {
          "command": "python",
          "args": ["-m", "horizon.mcp"],
          "env": {
            "HORIZON_API_KEY": "your-key",
            "HORIZON_EXCHANGE": "paper"
          }
        }
      }
    }
    ```
  </Step>

  <Step title="Use">
    Windsurf's Cascade will discover the Horizon tools and use them when you ask about trading.
  </Step>
</Steps>

## VS Code (Copilot)

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

  <Step title="Configure">
    Create `.vscode/mcp.json` in your workspace:

    ```json theme={null}
    {
      "servers": {
        "horizon": {
          "type": "stdio",
          "command": "python",
          "args": ["-m", "horizon.mcp"],
          "env": {
            "HORIZON_API_KEY": "your-key",
            "HORIZON_EXCHANGE": "paper"
          }
        }
      }
    }
    ```
  </Step>

  <Step title="Use">
    In the Copilot chat panel, switch to Agent mode. Copilot will discover the Horizon MCP tools.
  </Step>
</Steps>

## Live Trading

To switch from paper to a live exchange, update the `env` block:

<CodeGroup>
  ```json Polymarket theme={null}
  {
    "env": {
      "HORIZON_API_KEY": "your-key",
      "HORIZON_EXCHANGE": "polymarket",
      "POLYMARKET_API_KEY": "...",
      "POLYMARKET_API_SECRET": "...",
      "POLYMARKET_API_PASSPHRASE": "...",
      "POLYMARKET_PRIVATE_KEY": "0x..."
    }
  }
  ```

  ```json Kalshi theme={null}
  {
    "env": {
      "HORIZON_API_KEY": "your-key",
      "HORIZON_EXCHANGE": "kalshi",
      "KALSHI_API_KEY": "...",
      "KALSHI_EMAIL": "...",
      "KALSHI_PASSWORD": "..."
    }
  }
  ```
</CodeGroup>

<Warning>
  Never commit API keys to version control. Use environment variables or a secrets manager.
</Warning>

## HTTP Transport

For clients that support HTTP-based MCP (streamable HTTP), use:

```json theme={null}
{
  "horizon": {
    "command": "python",
    "args": ["-m", "horizon.mcp", "--http"]
  }
}
```

This starts the server on the default HTTP port instead of stdio.
