Skip to main content
Glama
samklein952-hub

Hyperliquid MCP Server

README.md
# ๐Ÿ”ฎ Hyperliquid MCP Server

[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
[![MCP](https://img.shields.io/badge/MCP-compatible-green.svg)](https://modelcontextprotocol.io)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

**The first MCP server for DeFi perpetual futures trading.** Let AI agents trade on [Hyperliquid](https://hyperliquid.xyz) โ€” the #1 decentralized derivatives exchange ($50B+ weekly volume).

> Trade perps, check positions, manage risk โ€” all through natural language via Claude, GPT, or any MCP-compatible AI agent.

## โšก Features

| Tool | Description |
|------|-------------|
| `get_account_info` | Wallet balance, margin, withdrawable funds |
| `list_markets` | All available perpetual futures markets |
| `get_market_info` | Price, funding rate, OI, 24h volume |
| `get_orderbook` | Live orderbook with configurable depth |
| `get_open_orders` | All pending orders |
| `get_positions` | Open positions with PnL & liquidation price |
| `place_order` | Limit or market orders |
| `cancel_order` | Cancel by order ID |
| `set_leverage` | Set leverage (cross or isolated) |
| `close_position` | Close positions (market or limit) |

## ๐Ÿš€ Quick Start

### 1. Install

```bash
pip install -e .
```

Or install dependencies directly:

```bash
pip install "mcp[server]" hyperliquid-python-sdk python-dotenv
```

### 2. Configure

```bash
cp .env.example .env
```

Edit `.env`:

```env
HYPERLIQUID_PRIVATE_KEY=your_private_key_here
HYPERLIQUID_WALLET_ADDRESS=0xYourAddress
HYPERLIQUID_TESTNET=true
```

> โš ๏ธ **Start with testnet!** Set `HYPERLIQUID_TESTNET=true` for paper trading.

### 3. Run

```bash
hyperliquid-mcp
# or
python -m hyperliquid_mcp.server
```

## ๐Ÿค– Claude Desktop Configuration

Add to your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "hyperliquid": {
      "command": "python",
      "args": ["-m", "hyperliquid_mcp.server"],
      "cwd": "/path/to/hyperliquid-mcp",
      "env": {
        "HYPERLIQUID_PRIVATE_KEY": "your_key",
        "HYPERLIQUID_WALLET_ADDRESS": "0xYourAddress",
        "HYPERLIQUID_TESTNET": "true"
      }
    }
  }
}
```

Or if installed via pip:

```json
{
  "mcpServers": {
    "hyperliquid": {
      "command": "hyperliquid-mcp",
      "env": {
        "HYPERLIQUID_PRIVATE_KEY": "your_key",
        "HYPERLIQUID_WALLET_ADDRESS": "0xYourAddress",
        "HYPERLIQUID_TESTNET": "true"
      }
    }
  }
}
```

## ๐Ÿ’ฌ Example Prompts

Once connected, try asking your AI agent:

- *"What's the current BTC funding rate on Hyperliquid?"*
- *"Show me the ETH orderbook, top 5 levels"*
- *"Set leverage to 5x on SOL and buy 10 SOL at market"*
- *"What are my open positions and total PnL?"*
- *"Close my ETH position at market price"*
- *"List all available markets and their max leverage"*

## ๐Ÿ”’ Security

- **Never commit your `.env` file** โ€” it contains your private key
- **Start with testnet** โ€” always test with paper money first
- **Review orders before confirming** โ€” AI agents can make mistakes
- Private keys are only used locally โ€” never transmitted except to Hyperliquid's API

## ๐Ÿ“‹ Requirements

- Python 3.10+
- A Hyperliquid wallet (testnet or mainnet)
- An MCP-compatible client (Claude Desktop, etc.)

## License

MIT

TDQS

A3.6/5.0

Scored across 10 tools

Disambiguation5/5

Each tool has a clearly distinct purpose in the trading lifecycle. Orders (place, cancel, get_open) are cleanly separated from positions (get, close), and market data tools (list_markets, get_market_info, get_orderbook) serve different information needs without overlap.

Naming Consistency5/5

Excellent consistency throughout. All tools use snake_case with clear verb_noun or get_noun patterns (e.g., place_order, get_account_info, list_markets). The verb choices (place, cancel, close, get, list, set) are precise and predictable.

Tool Count4/5

Ten tools is a reasonable scope for active trading operations, covering account, market data, orders, and positions. While the count is appropriate, a comprehensive trading surface might additionally include order history or modification tools, making it slightly lean.

Completeness4/5

Covers the core trading lifecycle well (account balance, market data, order management, position closing). Minor gaps include order history/fills, the ability to modify existing orders, and funding rate historyโ€”though agents can work around these by canceling/replacing orders and using current market data.

Maintenance

ActivityInactive
ResponsivenessNo issues