Hyperliquid MCP Server
A [Model Context Protocol (MCP)] server for interacting with Hyperliquid DEX.
Features
- Order Management: Place, modify, and cancel orders with support for both limit and market orders
- USD-Based Sizing: Specify order sizes in USD amounts for easier position sizing
- Leverage Control: Set and modify leverage for perpetual positions
- Account Analytics: Comprehensive P&L tracking, position monitoring, and balance queries
- Market Data: Access perpetual and spot market metadata
- Flexible Authentication: Separate accounts for trading operations and data queries
Installation
From PyPI (Recommended)
pip install -r requirements.txt
From Source
git clone https://github.com/OmChillure/hyperliquid
cd hyperliquid_mcp
pip install -e .
Quick Start
1. Running with uv/pip
If you prefer to run the server directly:
{
"mcpServers": {
"hyperliquid": {
"command": "python/uvx",
"args": ["/path/to/your/hyperliquid/server.py"],
"env": {
"HYPERLIQUID_MAIN_ACCOUNT_ADDRESS": "",
"HYPERLIQUID_API_ACCOUNT_ADDRESS": "",
"HYPERLIQUID_API_ACCOUNT_PRIVATE_KEY": ""
}
}
}
}
Available Tools
Trading Operations
placeOrder: Place limit or market orders with USD-based sizing supportmodifyOrder: Modify existing orderscancelOrder: Cancel orders by ID or client order ID
Account Management
getAccountState: Get comprehensive account information including P&L, positions, and balancesgetUserTradeHistory: Retrieve trade history and fill datagetUserSpotBalances: Query spot token balances
Market Data
getPerpetualsMeta: Get metadata for all perpetual marketsgetSpotMeta: Get metadata for all spot markets and tokens
Usage Examples
Place a Market Order
# Buy $100 worth of ETH at market price
await placeOrder(
coin="ETH",
is_buy=True,
usd_amount=100.0,
order_type="market"
)
Place a Limit Order with Leverage
# Place a limit buy order with 10x leverage
await placeOrder(
coin="BTC",
is_buy=True,
size=0.1,
price=45000.0,
order_type="limit",
leverage=10,
is_cross=False
)
Check Account State
# Get comprehensive account information
account_info = await getAccountState()
print(f"Total PnL: ${account_info['pnl_overview']['total_pnl']}")
print(f"Account Value: ${account_info['pnl_overview']['account_value']}")
Security Architecture
This MCP server uses a dual-account architecture for enhanced security:
- Main Account: Your primary trading account that holds funds. Used only for read-only operations.
- API Account: A separate account used exclusively for signing transactions. Should have minimal or no funds.
This separation means:
- Your main trading funds are never directly exposed
- The API account can be easily rotated if compromised
- You can grant specific permissions to the API account via Hyperliquid's interface
Environment Variables
| Variable | Description | Required |
|---|---|---|
HYPERLIQUID_MAIN_ACCOUNT_ADDRESS |
Your main trading account address | Yes |
HYPERLIQUID_API_ACCOUNT_ADDRESS |
API account address for signing | Yes |
HYPERLIQUID_API_ACCOUNT_PRIVATE_KEY |
Private key for API account | Yes |
HYPERLIQUID_BASE_URL |
Hyperliquid API endpoint | No (defaults to mainnet) |
Development
Setting up for Development
git clone https://github.com/yourusername/hyperliquid-mcp
cd hyperliquid-mcp
pip install -e ".[dev]"
Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Metadata
Release files for hl-mcp-server 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| hl_mcp_server-0.1.0.tar.gz | 8.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hl_mcp_server-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.3 kB
Release files / hl_mcp_server-0.1.0.tar.gz
| Download URL | hl_mcp_server-0.1.0.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b3029c79d9edec36a31c429b2c70f40c76d1f83cb659dcad1dbe1865dda0bb26
|
|
BLAKE2b-256 checksum How to use checksums |
a8214f12c88095dd46aa00246327a327f71d0773b679930dbe7c84c58f849386
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.4
|
Release files / hl_mcp_server-0.1.0-py3-none-any.whl
| Download URL | hl_mcp_server-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0b9c75f24413acd37a305e64c8a5073656b7de53bb6ff5c78faca85c3692c451
|
|
BLAKE2b-256 checksum How to use checksums |
908db791694916132787be070ccb0068873b1fdcf58e314701e2b7ae3e45e248
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.4
|
Security for hl-mcp-server 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.