Skip to main content
The Phantom MCP server includes a dedicated set of tools for perpetuals trading on Hyperliquid through Phantom’s backend. This page focuses only on those perps tools: what they do, how funding flows work, and the order agents should use them in.

Overview

Hyperliquid perps in the MCP server use two balances on Hypercore:
  • Spot account: receives bridged funds and holds transferable tokens
  • Perp account: holds USDC collateral for perpetual positions
The usual funding path is:
  1. external chain -> Hyperliquid spot
  2. Hyperliquid spot -> perp account
  3. open / manage positions
  4. perp account -> Hyperliquid spot
  5. Hyperliquid spot -> external chain
All perps write operations use the wallet’s EVM signing path on eip155:42161 for Hyperliquid actions. The funding tools are different: they use the Phantom bridge / swap flows where appropriate.

What agents can do with perps

These tools let an agent do more than just place a single trade. An agent can:
  • inspect available perp markets and compare price, funding, open interest, and leverage limits
  • check account value, available margin, and withdrawable balance
  • open long or short positions with configurable leverage
  • choose between market and limit orders
  • watch open positions and active orders over time
  • change leverage or margin mode after a trade is open
  • close part or all of a position when the user asks
  • move funds into and out of the perp account as part of a larger workflow
Typical user requests this enables:
  • “Open a 5x BTC long with $250 of exposure.”
  • “Place a limit ETH short if price comes back to 3,200.”
  • “Show me my open SOL perp and close half of it.”
  • “Move my remaining USDC out of perps and withdraw it back to Base.”
Perps tools can open leveraged positions and submit irreversible actions. Agents should confirm high-impact trades and withdrawals with the user before executing them.

Read-only tools

ToolWhat it returns
get_perp_marketsAvailable markets, price, funding, open interest, 24h volume, max leverage
get_perp_accountAccount value, available balance, available margin, withdrawable balance
get_perp_positionsOpen positions, size, direction, leverage, unrealized PnL, liquidation price
get_perp_ordersOpen orders including limit, TP, and SL orders
get_perp_trade_historyHistorical fills, fees, and closed PnL

Funding and withdrawal tools

deposit_to_hyperliquid

Bridges or swaps from an external chain into Hyperliquid. This is the entry point when funds are not already on Hypercore. Typical use:
  1. user has SOL / ETH / USDC on an external chain
  2. call deposit_to_hyperliquid
  3. funds arrive in Hyperliquid spot as USDC
  4. call transfer_spot_to_perps to move that USDC into the perp account
Example:
{
  "sourceChainId": "solana:mainnet",
  "amount": "10",
  "execute": true
}
Another example:
{
  "sourceChainId": "eip155:42161",
  "amount": "250",
  "sellTokenMint": "0xaf88d065e77c8cc2239327c5edb3a432268e5831",
  "execute": true
}

transfer_spot_to_perps

Moves USDC within Hypercore from spot into the perp account. This is an internal Hyperliquid transfer, not a bridge. Parameters:
  • amountUsdc: amount of USDC to move from spot to perps
  • derivationIndex (optional): account derivation index, defaults to 0
Example:
{
  "amountUsdc": "100"
}

withdraw_from_perps

Moves USDC within Hypercore from the perp account back to Hyperliquid spot. Parameters:
  • amountUsdc: amount of USDC to move from perps back to spot
  • derivationIndex (optional): account derivation index, defaults to 0
Example:
{
  "amountUsdc": "50"
}

withdraw_from_hyperliquid_spot

Bridges USDC from Hyperliquid spot to an external chain. This is the final step after withdraw_from_perps if the user wants funds off Hyperliquid. Parameters:
  • amountUsdc: amount of USDC to bridge out
  • destinationChainId: destination chain such as solana:mainnet, eip155:8453, eip155:42161
  • buyToken (optional): destination token if the user wants something other than default USDC
  • execute (optional): false returns a quote, true executes immediately
  • derivationIndex (optional): account derivation index, defaults to 0
Example:
{
  "amountUsdc": "25",
  "destinationChainId": "eip155:42161"
}
withdraw_from_perps does not bridge to an external chain. It only moves funds from perp -> spot on Hypercore. Use withdraw_from_hyperliquid_spot for the external-chain step.

Trading tools

open_perp_position

Opens a long or short position. Supports:
  • market orders
  • limit orders
  • leverage selection
  • isolated or cross margin
  • reduce-only flag
Parameters:
  • market: market symbol such as BTC, ETH, SOL
  • direction: long or short
  • sizeUsd: notional position size in USD
  • leverage: leverage multiplier
  • orderType: market or limit
  • limitPrice (required for limit orders): target price as a string
  • marginType (optional): isolated or cross
  • reduceOnly (optional): if true, order can only reduce an existing position
  • derivationIndex (optional): account derivation index, defaults to 0
Example (market long):
{
  "market": "ETH",
  "direction": "long",
  "sizeUsd": "100",
  "leverage": 5,
  "orderType": "market"
}
Example (limit short):
{
  "market": "BTC",
  "direction": "short",
  "sizeUsd": "500",
  "leverage": 10,
  "orderType": "limit",
  "limitPrice": "72000",
  "marginType": "isolated"
}

close_perp_position

Closes a position fully or partially using sizePercent. Parameters:
  • market: market symbol to close
  • sizePercent (optional): percentage of the position to close, defaults to 100
  • derivationIndex (optional): account derivation index, defaults to 0
Example:
{
  "market": "ETH",
  "sizePercent": 50
}

cancel_perp_order

Cancels an open order by orderId. Parameters:
  • market: market symbol
  • orderId: numeric order id from get_perp_orders
  • derivationIndex (optional): account derivation index, defaults to 0
Example:
{
  "market": "BTC",
  "orderId": 12345
}

update_perp_leverage

Changes leverage and margin mode for a market. Parameters:
  • market: market symbol
  • leverage: leverage multiplier
  • marginType: cross or isolated
  • derivationIndex (optional): account derivation index, defaults to 0
Example:
{
  "market": "SOL",
  "leverage": 3,
  "marginType": "cross"
}

Funding a perp account

  1. get_token_balances
  2. deposit_to_hyperliquid
  3. transfer_spot_to_perps
  4. get_perp_account

Opening and managing a trade

  1. get_perp_markets
  2. get_perp_account
  3. open_perp_position
  4. get_perp_positions
  5. get_perp_orders
  6. update_perp_leverage or cancel_perp_order as needed

Exiting and withdrawing

  1. close_perp_position
  2. withdraw_from_perps
  3. withdraw_from_hyperliquid_spot

Notes for agents

  • If the user asks for their total Hyperliquid exposure, do not rely only on get_token_balances; also call get_perp_account.
  • If the user asks to move funds off Hyperliquid, the full flow is usually withdraw_from_perps then withdraw_from_hyperliquid_spot.
  • If the user already has funds in Hyperliquid spot, skip deposit_to_hyperliquid and use transfer_spot_to_perps directly.

Tool reference

Full MCP tool parameters and examples, including non-perps tools.

MCP setup

Install and configure the Phantom MCP server.