A server that exposes a set of tools for interacting with the Hyperliquid decentralized exchange. It simplifies trading operations by providing a high-level API for placing, canceling, and modifying orders, as well as managing account settings and retrieving market data.
Project description
Hyperliquid MCP Server
A Model Context Protocol (MCP) server that provides comprehensive tools for interacting with the Hyperliquid decentralized exchange. This server enables AI assistants to perform trading operations, manage accounts, and retrieve market data through a standardized interface.
๐ Features
- Account Management - Positions, balances, transfers, and leverage control
- Order Management - Place, cancel, modify orders with advanced features
- Market Data - Real-time prices, orderbooks, candles, and funding rates
- Risk Management - Comprehensive validation and error handling
- Type Safety - Full Pydantic validation for all inputs
- Error Handling - Comprehensive error reporting and logging
๐ฆ Installation
Using uvx (Recommended)
uvx hyperliquid-mcp
Using uv
uv add hyperliquid-mcp
uv run hyperliquid-mcp
Using pip
pip install hyperliquid-mcp
hyperliquid-mcp
โ๏ธ Configuration
Environment Variables
Configure the following environment variables:
# Required for trading operations
export HYPERLIQUID_PRIVATE_KEY="your_private_key_here"
# Optional: Specify a different user address for queries (defaults to wallet address)
export HYPERLIQUID_USER_ADDRESS="0x1234567890123456789012345678901234567890"
# Optional: Use testnet instead of mainnet (default: false)
export HYPERLIQUID_TESTNET="true"
# Optional: Show detailed logs for debugging (default: false)
export HYPERLIQUID_MCP_SHOW_LOGS="false"
โ ๏ธ Security Warning: Never share your private key. The server will warn if the key is missing but will still start in read-only mode for market data.
Environment Variable Details
HYPERLIQUID_PRIVATE_KEY(Required for trading): Your wallet's private key for signing transactionsHYPERLIQUID_USER_ADDRESS(Optional): Ethereum address to query data for. If not set, uses the address derived from your private keyHYPERLIQUID_TESTNET(Optional): Set to"true"to use Hyperliquid's testnet for development and testingHYPERLIQUID_MCP_SHOW_LOGS(Optional): Set to"true"to enable detailed logging for debugging and development
๐ค User Address Configuration
The server supports querying data for different users:
- Default behavior: Uses the address derived from your
HYPERLIQUID_PRIVATE_KEY - Custom user: Set
HYPERLIQUID_USER_ADDRESSto query a different address - Tool-level override: Many tools accept a
userparameter to query specific addresses
Use cases:
- Monitor multiple accounts from one server instance
- Query public data for other traders (positions, fills, etc.)
- Portfolio management for multiple wallets
- Analytics and research on other users' trading activity
๐งช Testnet Configuration
For development and testing, you can use Hyperliquid's testnet:
- Enable testnet mode by setting
HYPERLIQUID_TESTNET=true - Get testnet tokens from the Hyperliquid testnet faucet
- Use testnet-specific addresses - testnet has separate contracts and addresses
- Test safely - All trades execute on testnet without real financial risk
๐ก Tip: Always test your trading strategies on testnet before using real funds on mainnet.
Claude Desktop Configuration
Add to your Claude Desktop claude_desktop_config.json:
{
"mcpServers": {
"hyperliquid": {
"command": "uvx",
"args": ["--no-progress","hyperliquid-mcp"],
"env": {
"HYPERLIQUID_PRIVATE_KEY": "your_private_key_here",
"HYPERLIQUID_USER_ADDRESS": "0x1234567890123456789012345678901234567890",
"HYPERLIQUID_TESTNET": "false",
"HYPERLIQUID_MCP_SHOW_LOGS": "false"
},
"transport": "stdio"
}
}
}
Alternative Configurations
Using uv directly:
{
"mcpServers": {
"hyperliquid": {
"command": "uv",
"args": ["run", "--with", "hyperliquid-mcp", "hyperliquid-mcp"],
"env": {
"HYPERLIQUID_PRIVATE_KEY": "your_private_key_here",
"HYPERLIQUID_USER_ADDRESS": "0x1234567890123456789012345678901234567890",
"HYPERLIQUID_TESTNET": "false",
"HYPERLIQUID_MCP_SHOW_LOGS": "false"
},
"transport": "stdio"
}
}
}
Local development:
{
"mcpServers": {
"hyperliquid": {
"command": "uv",
"args": ["run", "hyperliquid-mcp"],
"cwd": "/path/to/hyperliquid-mcp",
"env": {
"HYPERLIQUID_PRIVATE_KEY": "your_private_key_here",
"HYPERLIQUID_USER_ADDRESS": "0x1234567890123456789012345678901234567890",
"HYPERLIQUID_TESTNET": "true",
"HYPERLIQUID_MCP_SHOW_LOGS": "true"
},
"transport": "stdio"
}
}
}
๐ ๏ธ Available Tools
๐ค Account Management (5 tools)
get_positions
Get current trading positions and margin information.
- Input:
user(optional) - Ethereum address to query (defaults toHYPERLIQUID_USER_ADDRESSor wallet address) - Output: Positions and margin summary data
update_leverage
Modify leverage settings for a specific asset.
- Input:
asset,leverage(1-100),is_isolated(boolean) - Output: Leverage update confirmation
withdraw
Withdraw USDC to an external wallet.
- Input:
destination(Ethereum address),amount(minimum $1.01) - Output: Withdrawal confirmation
get_spot_user_state
Get spot trading account balances and state.
- Input:
user(optional) - Ethereum address to query - Output: Spot account balances and state
get_user_fees
Get user's current fee structure and rates.
- Input:
user(optional) - Ethereum address to query - Output: Fee information and tier details
๐ Market Data (5 tools)
get_market_data
Get current market data for a specific asset.
- Input:
asset- Asset symbol (e.g., "BTC", "ETH") - Output: Current price, volume, and market statistics
get_candle_data
Get historical OHLCV candlestick data.
- Input:
asset,interval(1m, 5m, 1h, 1d, etc.),start_time,end_time - Output: Historical price candles
get_l2_orderbook
Get Level 2 order book depth data.
- Input:
asset,significant_figures(optional, 1-10) - Output: Bid/ask levels with quantities
get_funding_rates
Retrieve current and historical funding rates for perpetual contracts.
- Input:
asset(optional),include_history(boolean),start_time(optional) - Output: Funding rate data
calculate_min_order_size
Calculate minimum order size for an asset to meet value requirements.
- Input:
asset,min_value_usd(default: $10) - Output: Minimum order size calculation
๐ Order Management (9 tools)
place_order
Place a new trading order on the exchange.
- Input: Order details including:
asset- Asset symbolis_buy- Order direction (boolean)size- Order quantityorder_type- "market", "limit", or "trigger"price- Order price (required for limit/trigger)time_in_force- "GTC", "IOC", or "ALO"reduce_only- Reduce-only flag (boolean)take_profit- Take profit price (optional)stop_loss- Stop loss price (optional)
- Output: Order placement confirmation with order ID
cancel_order
Cancel an existing order.
- Input:
asset,order_id - Output: Cancellation confirmation
modify_order
Modify price, size, or time-in-force of an existing order.
- Input:
asset,order_id,new_price(optional),new_size(optional),new_time_in_force(optional) - Output: Modification confirmation
get_open_orders
Retrieve all currently open orders.
- Input:
user(optional) - Ethereum address to query - Output: List of open orders with details
get_order_status
Check the status of a specific order.
- Input:
order_id,user(optional) - Output: Order status and execution details
bulk_cancel_orders
Cancel multiple orders in a single request.
- Input:
orders- List of orders with asset and order_id - Output: Bulk cancellation results
cancel_all_orders
Cancel all open orders, optionally filtered by asset.
- Input:
asset(optional) - Filter by specific asset - Output: Mass cancellation confirmation
get_user_fills
Get recent trade executions (fills).
- Input:
user(optional) - Ethereum address to query - Output: Recent trade execution data
get_user_fills_by_time
Get user's trade fills within a specific time range.
- Input:
start_time,end_time(optional),user(optional) - Output: Trade execution history
๐งช Testing
The project includes comprehensive tests covering all tools:
# Run all tests
make test
# Run with coverage
make test-cov
# Run specific test categories (use direct command for specific targets)
uv run pytest tests/test_server.py::TestAccountTools -v
๐ง Development
Setup Development Environment
# Clone the repository
git clone https://github.com/midodimori/hyperliquid-mcp.git
cd hyperliquid-mcp
# Install with development dependencies
make install-dev
# Run tests
make test
# Format and lint code
make format
# Check code style and types
make lint
# Run the server locally
make run
# See all available commands
make help
Project Structure
hyperliquid-mcp/
โโโ src/hyperliquid_mcp/
โ โโโ __init__.py
โ โโโ server.py # MCP server implementation
โ โโโ models.py # Pydantic models
โ โโโ logging_config.py # Logging configuration
โ โโโ tools/ # Tool implementations
โ โโโ __init__.py
โ โโโ base_client.py # Base client for Hyperliquid API
โ โโโ account.py # Account management tools
โ โโโ market.py # Market data tools
โ โโโ order.py # Order management tools
โโโ tests/
โ โโโ test_server.py # Tool function tests
โ โโโ test_mcp_integration.py # MCP integration tests
โโโ pyproject.toml # Project configuration
โโโ README.md
๐ API Reference
Order Types
- market: Execute immediately at current market price
- limit: Execute only at specified price or better
- trigger: Stop/trigger order that becomes market order when triggered
Time in Force
- GTC (Good Till Cancelled): Order remains active until filled or cancelled
- IOC (Immediate or Cancel): Fill immediately or cancel unfilled portion
- ALO (Add Liquidity Only): Only add liquidity, don't take from order book
Candle Intervals
Supported intervals: 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 8h, 12h, 1d, 3d, 1w, 1M
๐ค Contributing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add 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.
โ ๏ธ Disclaimer
This software is provided for educational and informational purposes only. Trading cryptocurrencies involves substantial risk and may result in significant financial losses. The authors are not responsible for any trading losses incurred through the use of this software. Always conduct your own research and consider consulting with a qualified financial advisor before making trading decisions.
๐ Links
- Hyperliquid Exchange
- Hyperliquid Documentation
- Model Context Protocol
- FastMCP Framework
- Claude Desktop
๐ Support
For questions, issues, or contributions:
- Open an issue on GitHub
- Check the Hyperliquid Discord for community support
- Review the comprehensive test suite for usage examples
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hyperliquid_mcp-1.0.3.tar.gz.
File metadata
- Download URL: hyperliquid_mcp-1.0.3.tar.gz
- Upload date:
- Size: 108.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ceb6549cc2bda96e878660e13c3441ce210a508ba92cbf7e050dec66b90afc4
|
|
| MD5 |
0902f26fb8ded36ce1f0f87ef4b4acee
|
|
| BLAKE2b-256 |
78bfa577f122ba8a6a346c45c5556f3d3f8c869a7bc710269bb833192d3b66fe
|
Provenance
The following attestation bundles were made for hyperliquid_mcp-1.0.3.tar.gz:
Publisher:
publish.yml on midodimori/hyperliquid-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hyperliquid_mcp-1.0.3.tar.gz -
Subject digest:
2ceb6549cc2bda96e878660e13c3441ce210a508ba92cbf7e050dec66b90afc4 - Sigstore transparency entry: 849583596
- Sigstore integration time:
-
Permalink:
midodimori/hyperliquid-mcp@a903e061dec90d15ae3428844730809994c120da -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/midodimori
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a903e061dec90d15ae3428844730809994c120da -
Trigger Event:
release
-
Statement type:
File details
Details for the file hyperliquid_mcp-1.0.3-py3-none-any.whl.
File metadata
- Download URL: hyperliquid_mcp-1.0.3-py3-none-any.whl
- Upload date:
- Size: 24.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cefa84a1c9d433a4792b20673c9a031732669b9499d61ef0bedb49e32a3d76ff
|
|
| MD5 |
dde94faabc10ee718c8a78083f0916f6
|
|
| BLAKE2b-256 |
4a9a92cbfaf4a3490ce8fc0d325f93e88c020e555d481ba61b890a6b8251a223
|
Provenance
The following attestation bundles were made for hyperliquid_mcp-1.0.3-py3-none-any.whl:
Publisher:
publish.yml on midodimori/hyperliquid-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hyperliquid_mcp-1.0.3-py3-none-any.whl -
Subject digest:
cefa84a1c9d433a4792b20673c9a031732669b9499d61ef0bedb49e32a3d76ff - Sigstore transparency entry: 849583619
- Sigstore integration time:
-
Permalink:
midodimori/hyperliquid-mcp@a903e061dec90d15ae3428844730809994c120da -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/midodimori
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a903e061dec90d15ae3428844730809994c120da -
Trigger Event:
release
-
Statement type: