Skip to main content
Glama
t3rmed

Hyperliquid MCP Server

by t3rmed

place_trigger_order

Execute stop-loss or take-profit orders on Hyperliquid DEX by setting trigger prices for automated position management and risk control.

Instructions

Place a trigger order (stop-loss or take-profit) 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
isMarketYesWhether to execute as market order when triggered
reduceOnlyNoWhether this is a reduce-only order (optional, default false)
sizeYesOrder size as string
triggerPriceYesTrigger price as string
triggerTypeYesTrigger type

Implementation Reference

  • Tool schema definition for place_trigger_order, including input parameters like assetIndex, isBuy, size, triggerPrice, etc.
    place_trigger_order_tool = Tool(
        name="place_trigger_order",
        description="Place a trigger order (stop-loss or take-profit) 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",
                },
                "size": {
                    "type": "string",
                    "description": "Order size as string",
                },
                "triggerPrice": {
                    "type": "string",
                    "description": "Trigger price as string",
                },
                "isMarket": {
                    "type": "boolean",
                    "description": "Whether to execute as market order when triggered",
                },
                "triggerType": {
                    "type": "string",
                    "description": "Trigger type",
                    "enum": ["tp", "sl"],
                },
                "reduceOnly": {
                    "type": "boolean",
                    "description": "Whether this is a reduce-only order (optional, default false)",
                },
                "clientOrderId": {
                    "type": "string",
                    "description": "Client order ID (optional)",
                },
            },
            "required": ["assetIndex", "isBuy", "size", "triggerPrice", "isMarket", "triggerType"],
        },
    )
  • The main handler function that processes the place_trigger_order tool call, constructs the OrderRequest with trigger type, and calls the HyperliquidClient to place the order.
    async def handle_place_trigger_order(client: HyperliquidClient, args: Dict[str, Any]) -> Dict[str, Any]:
        """Handle place trigger order request."""
        asset_index = args["assetIndex"]
        is_buy = args["isBuy"]
        size = args["size"]
        trigger_price = args["triggerPrice"]
        is_market = args["isMarket"]
        trigger_type = args["triggerType"]
        reduce_only = args.get("reduceOnly", False)
        client_order_id = args.get("clientOrderId")
    
        order = OrderRequest(
            a=asset_index,
            b=is_buy,
            p="0",  # Not used for trigger orders
            s=size,
            r=reduce_only,
            t={
                "trigger": TriggerOrderType(
                    triggerPx=trigger_price,
                    isMarket=is_market,
                    tpsl=trigger_type,
                )
            },
        )
    
        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 trigger order: {result.error}")
    
        return {
            "content": [
                TextContent(
                    type="text",
                    text=f"Trigger order placed successfully!\n\n{json.dumps(result.data, indent=2)}",
                )
            ]
        }
  • Registration of the place_trigger_order_tool in the MCP server's list_tools handler.
    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,
        ]
  • Dispatch/registration of the handle_place_trigger_order in the MCP call_tool handler for the name 'place_trigger_order'.
    async def call_tool(name: str, arguments: dict[str, Any] | None) -> list[TextContent]:
        """Handle tool calls."""
        args = arguments or {}
    
        try:
            if name == "get_all_mids":
                result = await handle_get_all_mids(client, args)
            elif name == "get_l2_book":
                result = await handle_get_l2_book(client, args)
            elif name == "get_candle_snapshot":
                result = await handle_get_candle_snapshot(client, args)
            elif name == "get_open_orders":
                result = await handle_get_open_orders(client, args)
            elif name == "get_user_fills":
                result = await handle_get_user_fills(client, args)
            elif name == "get_user_fills_by_time":
                result = await handle_get_user_fills_by_time(client, args)
            elif name == "get_portfolio":
                result = await handle_get_portfolio(client, args)
            elif name == "place_order":
                result = await handle_place_order(client, args)
            elif name == "place_trigger_order":
                result = await handle_place_trigger_order(client, args)
            elif name == "cancel_order":
                result = await handle_cancel_order(client, args)
            elif name == "cancel_all_orders":
                result = await handle_cancel_all_orders(client, args)
            else:
                raise ValueError(f"Unknown tool: {name}")
    
            return result["content"]
    
        except Exception as error:
            error_message = str(error)
            return [
                TextContent(
                    type="text",
                    text=f"Error: {error_message}",
                )
            ]
  • Registration of the handler in the TOOL_HANDLERS dict for the HTTP MCP server.
    TOOL_HANDLERS = {
        "get_all_mids": handle_get_all_mids,
        "get_l2_book": handle_get_l2_book,
        "get_candle_snapshot": handle_get_candle_snapshot,
        "get_open_orders": handle_get_open_orders,
        "get_user_fills": handle_get_user_fills,
        "get_user_fills_by_time": handle_get_user_fills_by_time,
        "get_portfolio": handle_get_portfolio,
        "place_order": handle_place_order,
        "place_trigger_order": handle_place_trigger_order,
        "cancel_order": handle_cancel_order,
        "cancel_all_orders": handle_cancel_all_orders,
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure but offers minimal information. It states what the tool does but doesn't describe execution behavior (what happens when triggered), potential risks, authentication requirements, rate limits, or error conditions. For a financial trading tool with no annotation coverage, this represents a significant transparency gap.

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 communicates the core purpose without unnecessary words. It's appropriately sized for a tool with comprehensive schema documentation and gets straight to the point with zero wasted verbiage.

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?

For a financial trading tool with 8 parameters, no annotations, and no output schema, the description is insufficient. It doesn't address critical context like execution mechanics, risk implications, authentication requirements, or response format. The combination of complex functionality with minimal behavioral disclosure creates significant gaps for an AI agent trying to use this tool appropriately.

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%, so the schema already documents all 8 parameters thoroughly. The description adds no additional parameter information beyond what's in the schema. The baseline score of 3 reflects adequate parameter documentation through the schema alone, though the description doesn't enhance understanding of parameter relationships or usage patterns.

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 a trigger order') and specifies the resource type ('stop-loss or take-profit') and platform ('on Hyperliquid'). It distinguishes from the sibling 'place_order' by focusing specifically on conditional trigger orders rather than immediate execution orders. However, it doesn't explicitly contrast with 'cancel_order' or other order management tools.

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 when trigger orders are appropriate compared to regular orders, nor does it reference the sibling 'place_order' for immediate execution needs. There's no discussion of prerequisites, timing considerations, or typical use cases for stop-loss versus take-profit orders.

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