Production-ready Model Context Protocol (MCP) server for Hyperliquid, built on the official Hyperliquid Python SDK.
No UI. No extra glue code. Just a reliable MCP backend you can run locally or in Docker.
Hyperliquid automation often fails at the operational layer (setup friction, env drift, brittle startup flows). This repository focuses on predictable deployment and safe defaults so you can run agents with confidence.
- SDK-native integration with Hyperliquid (official Python SDK only)
- Strict input validation for tool safety and deterministic behavior
- Standardized response schema (
ok,message,data, structurederror) - Docker-first runtime with clean startup/stop/reset workflows
- One-click Windows startup via
start.bat - Port fallback strategy for future exposed services (API/UI/metrics)
- Testnet-first default to reduce operational risk
- Python 3.12+
- MCP server runtime (
mcp) - Hyperliquid official SDK (
hyperliquid-python-sdk) - Docker + Docker Compose
- Install and launch Docker Desktop.
- In this repository root, double-click:
start.batWhat start.bat does:
- validates Docker availability and daemon state
- creates
.envfrom.env.example(if missing) - checks reserved ports (
APP_PORT,METRICS_PORT) - auto-switches occupied ports to free fallbacks
- runs
docker compose up --build -d - verifies that services are running and prints status
stop.batreset.batcp .env.example .env
# edit .env with your credentials
docker compose up --build -dTo stop:
docker compose stopTo reset:
docker compose down -v --remove-orphansThis server is intended for MCP-compatible clients (e.g., local agent runtimes).
python -m hyperliquid_mcp.server{
"mcpServers": {
"hyperliquid": {
"command": "python",
"args": ["-m", "hyperliquid_mcp.server"],
"env": {
"HYPERLIQUID_PRIVATE_KEY": "0x...",
"HYPERLIQUID_ACCOUNT_ADDRESS": "0x...",
"HYPERLIQUID_TESTNET": "true"
}
}
}
}HYPERLIQUID_PRIVATE_KEY
HYPERLIQUID_ACCOUNT_ADDRESSHYPERLIQUID_VAULT_ADDRESSHYPERLIQUID_TESTNET(trueby default)LOG_LEVEL
APP_PORT(default18080)METRICS_PORT(default19090)
The current MCP server communicates over stdio, so no host port mapping is required today. These vars are included to support future HTTP/metrics services without redesigning local workflows.
- The main service runs over stdio in Docker.
- No UI assumptions are made.
- Define all host ports in
.env(APP_PORT,METRICS_PORT, etc.). - In
docker-compose.yml, always reference env vars (${APP_PORT}) for mappings. start.batchecks whether reserved ports are already occupied.- If occupied, it increments to the next free port (up to 10 attempts).
- If no free port is found, it exits with an actionable error.
Use compose mappings like:
ports:
- "127.0.0.1:${APP_PORT:-18080}:8080"
- "127.0.0.1:${METRICS_PORT:-19090}:9090"This keeps startup stable across different local environments and prevents silent port conflicts.
- Start Docker Desktop and wait until it reports healthy.
- Re-run
start.bat.
- Check service state:
docker compose ps
- Check logs:
docker compose logs --tail=100
- Ensure
.envexists and contains a validHYPERLIQUID_PRIVATE_KEY. - Keep
HYPERLIQUID_TESTNET=trueunless you explicitly need mainnet.
- Run:
reset.bat
- This removes containers, volumes, and orphans.
- Never commit
.envor private keys. - Use dedicated automation wallets.
- Prefer testnet during development.
- Switch to mainnet only after validating tooling behavior.
- Optional HTTP bridge profile for non-stdio clients
- Healthcheck/metrics endpoint profile
- CI job for Docker compose smoke test
- Versioned release workflow for public distribution
MIT (see LICENSE).