Sponsored by Deepsite.site

Hyperliquid Trader Mcp

Created By
patricleehuaa month ago
一个封装了hyperliquid交易的mcp工具,可以给模型对hyperliquid进行交易
Content

中文🇨🇳

Hyperliquid MCP Trader

A trading toolchain built on the Model Context Protocol (MCP).
It wraps commonly used Hyperliquid Python SDK endpoints and exposes them as MCP tools:

  • get_mark_price(symbol): fetch the latest mark price
  • place_omarket/limit(symbol, side, qty, price, tif): place a market or limit order
  • place_spot_market/limit(...): spot entry points (not yet implemented in the current Hyperliquid SDK; calls raise NotImplementedError)
  • cancel_order(order_id): cancel an order by id
  • get_positions(dex): return current positions (dex can be empty, perp, or spot)
  • get_balances(dex): return balances and margin summaries (same dex options as above)

1. Environment Setup

  1. Install uv (pip install uv or follow the upstream guide).
  2. Create a virtual environment at the project root and sync dependencies:
    uv venv
    uv sync
    

    Prefer manual installs? Run uv pip install -r requirements.txt.

  3. Copy .env.example to .env (or export variables manually) and fill in real credentials:
    cp .env.example .env
    # Edit .env:
    # HL_ACCOUNT_ADDRESS=0xYourMainWalletAddress
    # HL_SECRET_KEY=0xYourApiWalletPrivateKey
    # HL_NETWORK=testnet  # or mainnet
    

Security tip: use Hyperliquid’s API wallet (trading permission only) and never commit real private keys.
Optional variables: HL_API_BASE_URL (custom endpoint), HL_SKIP_WS (set to true to skip WebSocket).

2. Run the MCP Server

uv run --env-file .env python -m app.mcp_server

By default the server speaks over stdin/stdout, which is ideal for local development.
To integrate with an MCP host (e.g., Claude Desktop, OpenAI Agents), register the same command in the host config.
Alternatively activate .venv manually and run python -m app.mcp_server.

To host over HTTP or SSE, specify the transport and network parameters:

# Streamable HTTP (defaults to 127.0.0.1:8000/mcp)
uv run --env-file .env python -m app.mcp_server --transport streamable-http --host 0.0.0.0 --port 9000

# SSE (works with OpenAI Agents, default mount path /sse)
uv run --env-file .env python -m app.mcp_server --transport sse

Environment variables are also supported: MCP_TRANSPORT=streamable-http, FASTMCP_HOST, FASTMCP_PORT, etc.

3. Troubleshooting

  • Ensure HL_ACCOUNT_ADDRESS and HL_SECRET_KEY match the chosen network (HL_NETWORK).
  • For rate limits (429) or timeouts, add retry/limit logic inside HLClient.
  • Always test on the testnet first; switch to mainnet only after validating the workflow.

The project structure follows patterns from Hyperliquid’s official/community SDK samples and the MCP Python SDK documentation.

HyperLiquid DEX

What is the Model Context Protocol (MCP)?

Server Config

{
  "mcpServers": {
    "Q2h0Fx49bWV0wT0hzIvcA": {
      "name": "hp交易",
      "type": "streamableHttp",
      "description": "",
      "isActive": true,
      "url": "http://0.0.0.0:9000/mcp",
      "installSource": "unknown"
    }
  }
}
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
ChatWiseThe second fastest AI chatbot™
Serper MCP ServerA Serper MCP Server
Playwright McpPlaywright MCP server
Tavily Mcp
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
DeepChatYour AI Partner on Desktop
WindsurfThe new purpose-built IDE to harness magic
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
CursorThe AI Code Editor
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Amap Maps高德地图官方 MCP Server
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.