Hyperliquid MCP Server
# ๐ฎ Hyperliquid MCP Server
[](https://www.python.org/downloads/)
[](https://modelcontextprotocol.io)
[](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
Scored across 10 tools
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.
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.
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.
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.