Hyperliquid MCP Server
A Model Context Protocol (MCP) server for interacting with the Hyperliquid DEX. This server provides tools for retrieving market data, managing positions, and executing trades on Hyperliquid.
Built with Python 3.11+ and uv package manager, with full Docker support for easy deployment.
Features
Market Data Tools
get_all_mids
- Get current mid prices for all coinsget_l2_book
- Get L2 order book snapshot for a specific coinget_candle_snapshot
- Get historical candle data
Account Information Tools
get_open_orders
- Get all open ordersget_user_fills
- Get trading history (fills)get_user_fills_by_time
- Get fills for a specific time rangeget_portfolio
- Get portfolio information including PnL and margin
Trading Tools
place_order
- Place limit ordersplace_trigger_order
- Place stop-loss or take-profit orderscancel_order
- Cancel specific orderscancel_all_orders
- Cancel all open orders
Installation
Prerequisites
Python 3.11 or higher
uv package manager
Docker (optional, for containerized deployment)
Local Installation
Clone this repository
Install dependencies with uv:
uv syncRun the server:
uv run python -m hyperliquid_mcp_server.main
Docker Installation
Clone this repository
Build and run with Docker Compose:
# Production mode make build && make run # Or using docker-compose directly docker-compose up --buildFor development with hot reloading:
# Development mode make dev # Or using docker-compose directly docker-compose --profile dev up --build
Configuration
Configure the server using environment variables:
Required for Trading Operations
HYPERLIQUID_PRIVATE_KEY
- Your wallet's private key (with 0x prefix)
Optional
HYPERLIQUID_WALLET_ADDRESS
- Your wallet address (derived from private key if not provided)HYPERLIQUID_TESTNET
- Set to "true" for testnet, "false" or unset for mainnet
Example Environment Setup
Create a .env
file (not recommended for production):
Usage
Using Make Commands
The project includes a Makefile for common operations:
Manual Commands
With Claude Desktop
Add this server to your Claude Desktop configuration:
Local Installation
Docker Installation
API Reference
Market Data
get_all_mids
Get current mid prices for all coins.
get_l2_book
Get L2 order book for a specific coin.
get_candle_snapshot
Get historical candle data.
Account Information
get_open_orders
Get open orders for the configured wallet or a specific user.
get_user_fills
Get trading history.
get_portfolio
Get portfolio information.
Trading
place_order
Place a limit order.
place_trigger_order
Place a trigger order (stop-loss/take-profit).
cancel_order
Cancel a specific order.
cancel_all_orders
Cancel all open orders.
Security Notes
Never share your private key
Use testnet for development and testing
Consider using environment variables or secure secret management for production
This server requires your private key to sign trading transactions
Read-only operations (market data, account info) work without a private key
Asset Indices
Common asset indices for Hyperliquid:
BTC: 0
ETH: 1
SOL: 2
(Check Hyperliquid documentation for complete list)
Error Handling
The server includes comprehensive error handling:
Invalid configurations are reported on startup
API errors are caught and returned with descriptive messages
Network timeouts are handled gracefully
Input validation prevents malformed requests
Development
Project Structure
Development Setup
Docker Development
License
MIT
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Tools
Enables interaction with the Hyperliquid DEX for retrieving market data, managing positions, and executing trades. Supports both testnet and mainnet operations with comprehensive trading tools including order placement, cancellation, and portfolio management.