Skip to main content
Glama
t3rmed

Hyperliquid MCP Server

by t3rmed

place_order

Execute limit or trigger orders on Hyperliquid DEX to buy or sell crypto assets. Specify asset, direction, price, size, and time parameters to manage trading positions.

Instructions

Place a limit or trigger order on Hyperliquid

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
assetIndexYesAsset index for the coin (0 for BTC, 1 for ETH, etc.)
clientOrderIdNoClient order ID (optional)
isBuyYesTrue for buy order, false for sell order
priceYesOrder price as string
reduceOnlyNoWhether this is a reduce-only order (optional, default false)
sizeYesOrder size as string
timeInForceYesTime in force

Implementation Reference

  • The main handler function for the 'place_order' tool. It parses input arguments, constructs an OrderRequest and PlaceOrderAction, calls the HyperliquidClient's place_order method, and returns a formatted response.
    async def handle_place_order(client: HyperliquidClient, args: Dict[str, Any]) -> Dict[str, Any]:
        """Handle place order request."""
        asset_index = args["assetIndex"]
        is_buy = args["isBuy"]
        price = args["price"]
        size = args["size"]
        reduce_only = args.get("reduceOnly", False)
        time_in_force = args["timeInForce"]
        client_order_id = args.get("clientOrderId")
    
        order = OrderRequest(
            a=asset_index,
            b=is_buy,
            p=price,
            s=size,
            r=reduce_only,
            t={"limit": LimitOrderType(tif=time_in_force)},
        )
    
        if client_order_id:
            order.c = client_order_id
    
        action = PlaceOrderAction(orders=[order])
        result = await client.place_order(action)
    
        if not result.success:
            raise ValueError(f"Failed to place order: {result.error}")
    
        return {
            "content": [
                TextContent(
                    type="text",
                    text=f"Order placed successfully!\n\n{json.dumps(result.data, indent=2)}",
                )
            ]
        }
  • Defines the Tool object for 'place_order' including name, description, and detailed input schema for validation.
    place_order_tool = Tool(
        name="place_order",
        description="Place a limit or trigger order on Hyperliquid",
        inputSchema={
            "type": "object",
            "properties": {
                "assetIndex": {
                    "type": "number",
                    "description": "Asset index for the coin (0 for BTC, 1 for ETH, etc.)",
                },
                "isBuy": {
                    "type": "boolean",
                    "description": "True for buy order, false for sell order",
                },
                "price": {
                    "type": "string",
                    "description": "Order price as string",
                },
                "size": {
                    "type": "string",
                    "description": "Order size as string",
                },
                "reduceOnly": {
                    "type": "boolean",
                    "description": "Whether this is a reduce-only order (optional, default false)",
                },
                "timeInForce": {
                    "type": "string",
                    "description": "Time in force",
                    "enum": ["Gtc", "Ioc", "Alo"],
                },
                "clientOrderId": {
                    "type": "string",
                    "description": "Client order ID (optional)",
                },
            },
            "required": ["assetIndex", "isBuy", "price", "size", "timeInForce"],
        },
    )
  • Registers the 'place_order' tool (via place_order_tool) in the MCP server's list of available tools.
    @app.list_tools()
    async def list_tools() -> list:
        """List all available tools."""
        return [
            # Market data tools
            get_all_mids_tool,
            get_l2_book_tool,
            get_candle_snapshot_tool,
            # Account info tools
            get_open_orders_tool,
            get_user_fills_tool,
            get_user_fills_by_time_tool,
            get_portfolio_tool,
            # Trading tools
            place_order_tool,
            place_trigger_order_tool,
            cancel_order_tool,
            cancel_all_orders_tool,
        ]
  • Dispatches tool calls to the 'handle_place_order' function when 'place_order' is requested.
        result = await handle_get_portfolio(client, args)
    elif name == "place_order":
        result = await handle_place_order(client, args)
    elif name == "place_trigger_order":
  • Core helper method in HyperliquidClient that signs and submits the place order action to the Hyperliquid API.
    async def place_order(self, action: PlaceOrderAction) -> ApiResponse[Any]:
        """Place an order."""
        try:
            if not self.account:
                raise ValueError("Private key required for trading operations")
    
            nonce = self._generate_nonce()
            signature = await self._sign_action(action.model_dump(), nonce)
    
            payload = {
                "action": action.model_dump(),
                "nonce": nonce,
                "signature": signature,
                "vaultAddress": self.config.wallet_address,
            }
    
            response = await self.client.post("/exchange", json=payload)
            response.raise_for_status()
            return ApiResponse(success=True, data=response.json())
        except Exception as e:
            return ApiResponse(success=False, error=str(e))
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool places orders but doesn't mention critical traits like authentication requirements, rate limits, potential side effects (e.g., fund deductions), error handling, or response format. For a financial transaction tool, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's function without unnecessary words. It's front-loaded and wastes no space, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a financial order placement tool with no annotations and no output schema, the description is insufficient. It lacks details on authentication, error cases, return values, and differentiation from siblings like 'place_trigger_order', leaving critical context gaps for safe and effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with each parameter well-documented in the schema (e.g., assetIndex mapping, isBuy meaning). The description adds no additional parameter semantics beyond the schema, so it meets the baseline of 3 for high coverage without extra value.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('place') and resource ('limit or trigger order on Hyperliquid'), making the purpose evident. However, it doesn't distinguish this tool from its sibling 'place_trigger_order', which appears to be a more specific variant, leaving some ambiguity about when to use one versus the other.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., authentication, account setup), compare it to 'place_trigger_order', or indicate scenarios where it's appropriate (e.g., trading strategies). This lack of context makes it harder for an agent to decide when to invoke it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/t3rmed/hyperliquid-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server