- An MCP server exposing tools to interact with Hyperliquid via HTTP.
- Built with FastAPI; reads your MetaMask private key from
.env. - Ships with a stub client so you can run it without the Hyperliquid SDK. Swap to the real SDK when ready.
/health: Health check./mcp/tools(POST): Advertises available tools (schemas included)./mcp/call(POST): Executes tools (get_all_mids,place_limit_order).
- Create
.envat repo root:
PRIVATE_KEY=replace_with_your_metamask_private_key
- Keep
.envout of version control. - Use the raw private key (hex), not the seed phrase.
- Install deps:
pip install -r requirements.txt
- Run the server:
uvicorn server:app --reload --host 0.0.0.0 --port 8000
- Try it:
curl -s http://127.0.0.1:8000/health
curl -s -X POST http://127.0.0.1:8000/mcp/tools -H 'Content-Type: application/json' -d '{}'
curl -s -X POST http://127.0.0.1:8000/mcp/call -H 'Content-Type: application/json' -d '{"toolName":"get_all_mids","arguments":{}}'
-
get_all_mids- Params: none
- Returns:
{ [coin: string]: number }
-
place_limit_order- Params:
coin: string (e.g. "BTC")side: string ("buy" | "sell")size: numberlimit_price: numbertime_in_force(optional): "Gtc" | "Ioc" | "Alo" (default "Gtc")reduce_only(optional): boolean (default false)
- Params:
Example call:
curl -s -X POST http://127.0.0.1:8000/mcp/call \
-H 'Content-Type: application/json' \
-d '{
"toolName":"place_limit_order",
"arguments": {"coin":"BTC","side":"buy","size":0.1,"limit_price":60000}
}'
- By default,
mcp_tools.pytries to import the Hyperliquid SDK.- If present: it will initialize real
ExchangeClient/InfoClientand you can trade on testnet/mainnet. - If missing: it falls back to a stub (returns demo mids and mock order responses). No funds, no fees.
- If present: it will initialize real
Switch networks in server.py by passing is_testnet=True to init_hyperliquid_client.
- Never commit your real private key.
.envis ignored. - Prefer running on testnet until you validate end-to-end behavior.
-
Import warnings (fastapi, pydantic, dotenv):
- Run
pip install -r requirements.txt.
- Run
-
Hyperliquid SDK not found:
- Server still runs using the stub. To use the real SDK, install the official package and replace stubbed calls as needed.
-
404 Unknown tool:
- Ensure
toolNamematches exactly:get_all_midsorplace_limit_order.
- Ensure