Labsco
erscoder logo

hyperliquid-mcp

from erscoder

Control your Hyperliquid perps from Claude (or any MCP client) using natural language.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeQuick setup

๐ŸŸข Hyperliquid MCP

Control your Hyperliquid perps from Claude (or any MCP client) using natural language.

"What's my BTC PnL?" โ†’ Claude fetches your positions and answers in seconds.
"Buy 0.1 ETH at market" โ†’ Claude places the order via Hyperliquid API.

Built with the Model Context Protocol โ€” the open standard for connecting AI to external tools.


โœจ Features

ToolDescription
hl_get_all_midsPrices for all assets
hl_get_orderbookL2 bids/asks for any asset
hl_get_metaMarket info (leverage, tick size)
hl_get_candlesOHLCV history (1m โ†’ 1d)
hl_get_user_statePositions, equity, margin, PnL
hl_get_open_ordersActive orders
hl_get_fillsTrade history
hl_get_funding_historyFunding rate history
hl_place_orderPlace limit or market orders
hl_cancel_orderCancel specific order
hl_cancel_all_ordersCancel all orders (optional: by coin)
hl_close_positionClose entire position
hl_set_leverageSet leverage (cross or isolated)

๐Ÿ”’ Security

  • Your keys never leave your machine. The server runs locally via stdio transport.
  • Read-only by default. Set only HL_WALLET_ADDRESS if you don't want trading enabled.
  • Trading requires HL_PRIVATE_KEY. Without it, all trading tools return an error.
  • Use a dedicated trading wallet with limited funds for extra safety.

๐Ÿค– Use in AI Agents

MCP is not just for chat clients. Use hyperliquid-mcp as the trading layer inside any autonomous agent.

LangChain / LangGraph

from langchain_mcp_adapters.client import MultiServerMCPClient

client = MultiServerMCPClient({
    "hyperliquid": {
        "command": "uvx",
        "args": ["hyperliquid-mcp"],
        "transport": "stdio",
        "env": {"HL_WALLET_ADDRESS": "0xYourWallet"}
    }
})

tools = await client.get_tools()
# tools now includes hl_get_user_state, hl_get_orderbook, etc.
# Pass them to any LangChain agent or LangGraph node

CrewAI

from crewai import Agent
from crewai_tools import MCPTool

hl_tools = MCPTool.from_server(
    command="uvx",
    args=["hyperliquid-mcp"],
    env={"HL_WALLET_ADDRESS": "0xYourWallet"}
)

trader = Agent(
    role="Trading Analyst",
    goal="Monitor Hyperliquid positions and funding rates",
    tools=hl_tools
)

Custom agent (MCP Python SDK)

from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

server_params = StdioServerParameters(
    command="uvx",
    args=["hyperliquid-mcp"],
    env={"HL_WALLET_ADDRESS": "0xYourWallet"}
)

async with stdio_client(server_params) as (read, write):
    async with ClientSession(read, write) as session:
        await session.initialize()
        result = await session.call_tool("hl_get_user_state", {})
        print(result.content)

Agent ideas:

  • Portfolio monitor that alerts when funding rates spike above threshold
  • Risk manager that auto-closes positions when drawdown exceeds limit
  • Arbitrage scanner comparing funding across assets
  • Morning briefing agent that summarizes overnight PnL and open positions

๐Ÿ’ฌ Other MCP Clients

Works with any MCP-compatible client:

  • Claude Desktop โ€” see Quick Start above
  • VS Code (Copilot) โ€” add to .vscode/mcp.json
  • Cursor โ€” add to MCP settings
  • Continue.dev โ€” add to config

๐Ÿ“„ License

MIT โ€” free to use, fork, and contribute.


๐ŸŒŸ Star History

If this saved you time, a โญ goes a long way!