Skip to main content
Glama
Hyperliquid

Hyperliquid

by cryptolir

AgentGlob Trader

CI

Open-source trading tools for AI agents. An MCP server and a set of agent skills that let an AI agent read markets and trade Hyperliquid perpetual futures — without ever holding a private key.

Built and used in production by AgentGlob.


The idea: the agent never holds the key

Most "AI trading bot" setups hand the model an API key and hope the prompt holds. This one does not.

   AI agent  ──►  MCP server  ──►  AgentGlob runtime  ──►  Hyperliquid
  (the model)    (this repo)      (keys, caps, signing)     (exchange)
     no key         no key          the only signer

The MCP server in this repo holds no credential and never contacts the exchange. It calls an authenticated runtime API, which owns the delegated trading key, enforces the owner's limits, and signs. The model's job is to ask — and every refusal is decided somewhere the model cannot reach.

Practical consequences:

  • A prompt injection cannot lift a limit. Caps live behind the API, not in the context window. An order over the cap comes back 403 order_cap_exceeded no matter how convincingly the model was asked.

  • There is no withdrawal path in the code at all. Not disabled by a flag — absent. No function builds one, so nothing can sign one. Funds cannot leave the account through these tools.

  • Trading uses a delegated key, not your wallet key. Hyperliquid's API wallets can sign orders for an account but cannot move funds off it.

Related MCP server: Hyperliquid MCP

What is here

mcp/hyperliquid/

The MCP server — 9 typed tools for market data, account reads, orders, leverage, funding and stablecoin conversion

skills/

Three agent skills: how to read the market, how to trade, and how to size a trade so it stays inside its limits

The tools

Tool

Does

hl_market_data

Mid prices, order book, candles, funding rates, perp metadata

hl_account

This agent's own positions, margin, balances, open orders, fills

hl_place_order

Limit order, long or short, with reduce-only and time-in-force

hl_cancel_order

Cancel one resting order by id

hl_set_leverage

Per-asset leverage, cross or isolated

hl_transfer

Move USDC from spot to perp so it can back a trade

hl_transfer_status

Reconcile an in-flight transfer against the exchange ledger

hl_swap

Convert USDH, USDT0 or USDE into USDC — never below $0.99

hl_account_status

Trading readiness: key present, approval valid, expiry

Account reads are always this agent's own account. There is no parameter for someone else's address; the server fills it in.

The skills are the interesting half

The MCP gives a model capability. The skills give it judgement — and most of what an agent gets wrong about trading is judgement, not syntax.

  • hyperliquid-monitor — reading the market and the account. Which number actually answers "how much is in there", why szi carries the direction in its sign, and why a shared rate limit means your polling loop is not yours alone.

  • hyperliquid-trading — placing and cancelling. Why ok: true does not mean the order is live, why there are no market orders, no stop-losses and no modify, and what every refusal code means.

  • hyperliquid-risk — sizing and leverage. Why every order costs its full size against the daily budget even if it never fills, why that means an agent can spend its whole allowance opening positions and then be unable to close them, and why liquidation distance is the one number worth reporting unprompted.

They are plain Markdown. Read them even if you never run this code — they document a lot of hard-won detail about agents and this exchange.

Using it

This repo has three parts, and each one travels differently:

Part

Works with other agents?

The skills

Yes, any agent. Plain Markdown that any skill-aware runtime can load.

The MCP server

Yes, any MCP client — Claude Code, Claude Desktop, Cursor, OpenClaw and others. It needs a backend to talk to.

AgentGlob's backend

Only for agents running on AgentGlob.

That last line is on purpose. AgentGlob's backend only accepts calls from the agents it hosts. If someone copies an agent's token onto a laptop, every call from there is refused. So a leaked token is useless to anyone else.

On AgentGlob (works out of the box)

AgentGlob gives an AI agent a persistent home: its own container, its own wallet, its own memory, and a dashboard where a human stays in charge of what it may do.

  1. Create an agent in the dashboard.

  2. Wallet tab → generate a wallet, then provision a Trading Key. The trading key is a Hyperliquid API wallet: it signs orders and cannot withdraw. Your wallet key never enters the agent's container.

  3. Set the caps — per-order size, daily total, maximum leverage, and which assets are allowed. The agent cannot change these and cannot read them.

  4. Tools tab → add the Hyperliquid MCP. Add the skills from the catalog.

The agent can now trade, inside limits you set, and you can watch every order and change the rules at any time — including switching trading off mid-position.

Every agent in a workspace can have it. Each one gets its own Trading Key and its own limits, so a cautious agent and an active one can sit side by side.

Skills in any agent

The skills are useful even without these tools: they teach an agent how Hyperliquid really behaves (see skills/).

Claude Code — copy them into your skills folder:

git clone https://github.com/cryptolir/AgentGlob-Trader
cp -r AgentGlob-Trader/skills/hyperliquid-* ~/.claude/skills/

Other runtimes — copy the three hyperliquid-* folders to wherever your runtime reads skills from. Each is a SKILL.md with the standard name and description frontmatter.

One thing to adapt: when something needs a human, the skills tell the agent to ask its owner to use the AgentGlob dashboard (the Wallet tab, for example). Elsewhere, that means whoever runs your backend.

The MCP server in any MCP client

The server needs Node 20 or newer, and two settings:

Setting

Value

AGENTGLOB_RUNTIME_URL

Your backend's address

AGENTGLOB_RUNTIME_TOKEN

The token your backend expects

Claude Code:

claude mcp add hyperliquid \
  -e AGENTGLOB_RUNTIME_URL=https://your-backend.example \
  -e AGENTGLOB_RUNTIME_TOKEN=your-token \
  -- npx -y github:cryptolir/AgentGlob-Trader

Claude Desktop, Cursor and most other clients take the same thing as JSON — Claude Desktop in claude_desktop_config.json (Settings → Developer → Edit Config), Cursor in ~/.cursor/mcp.json:

{
  "mcpServers": {
    "hyperliquid": {
      "command": "npx",
      "args": ["-y", "github:cryptolir/AgentGlob-Trader"],
      "env": {
        "AGENTGLOB_RUNTIME_URL": "https://your-backend.example",
        "AGENTGLOB_RUNTIME_TOKEN": "your-token"
      }
    }
  }
}

npx downloads the repo, builds it and starts the server. If a setting is missing, it stops at once with a message saying which.

The backend is yours to write. It is small — eight endpoints, all listed in mcp/hyperliquid/README.md. It is also where every safety rule lives: the key, the limits and the signing. Do not move them into the MCP server — the whole point is that the agent can reach the server, so the server cannot be the thing that protects you.

Or skip writing a backend: run the agent on AgentGlob.

From source

git clone https://github.com/cryptolir/AgentGlob-Trader
cd AgentGlob-Trader
npm install   # also builds, into dist/
npm test

npm start runs the server once the two settings are set.

The safety model, stated plainly

  • Caps are server-side. Per-order notional, daily notional, max leverage, asset allowlist. The agent cannot read them or raise them; an order that tries to set its own is refused as an attempt, not a typo.

  • An empty allowlist allows nothing. Absence is never permission.

  • Funding moves one direction only — spot to perp. Perp back to spot is not restricted, it is not built: there is no code that constructs it.

  • The one spot action is narrow by construction. hl_swap converts three hand-picked stablecoins into USDC and nothing else — it cannot buy a coin whose price moves. Its limit price is its floor, so it never sells below $0.99; a coin that has lost its $1 value simply does not sell. It reuses the ordinary order action, so it adds nothing new that a key could sign.

  • Mainnet only, small sizes. No paper mode. The safety comes from the caps and from position sizes a person chose, not from a sandbox.

What it still cannot protect you from

Worth saying out loud, because the skills say it to the agent too:

  • There is no stop-loss. Hyperliquid has no resting protective order here, and nothing closes a losing position while the agent is not looking.

  • An agent can lose money inside its caps. The caps bound the size of a mistake, not whether one happens.

  • Nothing here is financial advice, and the skills instruct the agent to refuse to give any.

Integration plans

  • QuantConnect integration — use QuantConnect for strategy research, backtesting and optimization while keeping Hyperliquid execution behind AgentGlob's existing runtime controls.

  • Platform research — short, plain-English summaries of outside platforms (QuantConnect, Binance, LEAN, Hummingbot) and how they could work with an AgentGlob trading agent.

Contributing

Issues and pull requests welcome — especially additional venues. The shape here (thin typed MCP + skills that carry the judgement + server-side caps) is meant to be reusable for other exchanges.

npm install builds and npm test runs the tests — the same checks run on every pull request.

License

Apache License 2.0 — see LICENSE.

Available Tools

9 tools
hl_accountA

Read this agent's own Hyperliquid account: perp positions and margin, spot balances, open orders, recent fills, or portfolio history. The address is always this agent's own bound wallet — it cannot be pointed at another account.

Inputs: kind (required).

hl_account_statusA

Trading readiness for this agent's own account: whether Hyperliquid is enabled, the Trading Key is present, the exchange still honours its approval, and when that approval expires. Use this to explain WHY an order might be refused, instead of discovering it from the refusal.

Inputs: no named parameters.

hl_cancel_orderA

Cancel one resting order by its order id (oid), which comes from hl_account with kind=openOrders.

Inputs: oid (required), coin (required).

hl_market_dataA

Read Hyperliquid market data: mid prices, the order book, candles, or perp metadata (asset list, size precision, max leverage). No account access, no signing.

Inputs: kind (required), coin, endTime, interval, +1 more.

hl_place_orderA

Place a limit order on Hyperliquid. Subject to owner-set limits: per-order and daily notional caps, a maximum leverage, and an asset allowlist. Exceeding a limit returns 403 with a cap_* code — do not retry or attempt to work around it. Hyperliquid has no market order: to cross the spread, send an aggressive limit price and accept the slippage explicitly.

Inputs: px (required), sz (required), coin (required), isBuy (required), +2 more.

hl_set_leverageA

Set leverage for one asset. Bounded by the owner-set maximum; a higher value returns 403 leverage_exceeded. Raising leverage raises liquidation risk on any open position.

Inputs: coin (required), leverage (required), isCross.

hl_swapA

Convert a stablecoin held on the spot side — USDH, USDT0 or USDE — into USDC, so it can back perp trades. Only those three coins, only into USDC, and never below 0.99 USDC per coin: if no buyer pays that much, nothing sells. This is not spot trading and cannot buy any other coin. Minimum 11 (at the 0.99 floor that clears the exchange minimum of $10). It can fill partly — report soldSz and usdcReceived, not the amount asked for. Counts against the owner-set daily limit; only what actually sold is charged.

Inputs: from (required), amount (required).

hl_transferA

Move USDC from the spot account into the perp account so it can back trades. This is the ONLY direction — perp-to-spot does not exist here, deliberately. Amount is whole US dollars (no cents: the dashboard sets the cents as a tracking tag and sends slightly less than requested). One transfer at a time per account; if one is unresolved, reconcile with hl_transfer_status before retrying. Bounded by the owner-set daily limit.

Inputs: amount (required), direction (required).

hl_transfer_statusA

Reconcile the account's in-flight transfer against the exchange ledger: reports landed, still-pending (with whether a retry is allowed yet), or blocked (an owner must clear a double-land).

Inputs: no named parameters.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 9 tools

    Disambiguation4/5

    Each tool targets a distinct action (read market, read account, place, cancel, leverage, transfer, swap, status). The only mild overlaps are the paired read/write tools (hl_account vs hl_account_status, hl_transfer vs hl_transfer_status), but descriptions clearly differentiate them, so confusion is unlikely.

    Naming Consistency4/5

    All tools use a consistent hl_ prefix and snake_case, mostly verb_noun (hl_place_order, hl_cancel_order, hl_set_leverage). A few are noun-only or noun_status (hl_account, hl_market_data, hl_swap, hl_account_status), a minor deviation from the pattern.

    Tool Count5/5

    Nine tools is well-scoped for a trading server: reads, order management, leverage, funding movement, and readiness checks, with each tool earning its place. No redundant or filler tools.

    Completeness4/5

    Covers the core trading lifecycle: market data, account reads, place/cancel orders, leverage, transfers, swap, and status. Minor gaps like an amend/modify order, cancel-all, or direct order-status-by-id (only open-orders listing exists) are workable but slightly incomplete.

    Maintenance

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol (MCP) server for the Hyperliquid decentralized exchange, enabling AI assistants to perform trading operations, manage accounts, and retrieve market data.
      29 PyPI
      3
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables natural language control of Hyperliquid perpetual futures, including querying positions, prices, orderbook, and executing trades like market and limit orders, all from MCP-compatible clients.
      13
      MIT
    • F
      license
      Not graded
      quality
      C
      maintenance
      MCP server for Hyperliquid perpetual DEX with 48 tools for trading, monitoring, risk management, and security. Enables real-time market data, order management, risk validation, and automated trading strategies.
      -
    • A
      license
      A
      quality
      D
      maintenance
      A read-only MCP server for querying Hyperliquid perp markets, funding rates, order books, candles, and account positions/fills/funding for any address, without needing API keys or wallets.
      8
      56 npm
      2
      MIT