Skip to main content
Glama
t3rmed

Hyperliquid MCP Server

by t3rmed

get_open_orders

Retrieve all active trading orders for your Hyperliquid DEX wallet to monitor pending trades and manage your portfolio effectively.

Instructions

Get all open orders for the configured wallet or a specific user

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
userNoUser wallet address (optional, defaults to configured wallet)

Implementation Reference

  • Handler function that processes the tool call, invokes the Hyperliquid client, and formats open orders into a text response.
    async def handle_get_open_orders(client: HyperliquidClient, args: Dict[str, Any]) -> Dict[str, Any]:
        """Handle get open orders request."""
        user = args.get("user")
        result = await client.get_open_orders(user)
    
        if not result.success:
            raise ValueError(f"Failed to get open orders: {result.error}")
    
        orders = result.data or []
    
        if not orders:
            return {
                "content": [
                    TextContent(
                        type="text",
                        text="No open orders found.",
                    )
                ]
            }
    
        orders_text = "\n".join(
            f"{order['coin']} {'BUY' if order['side'] == 'B' else 'SELL'} {order['sz']} @ {order['px']} (ID: {order['oid']})"
            for order in orders
        )
    
        return {
            "content": [
                TextContent(
                    type="text",
                    text=f"Open Orders ({len(orders)}):\n\n{orders_text}",
                )
            ]
        }
  • MCP Tool object defining the name, description, and input schema for get_open_orders.
    get_open_orders_tool = Tool(
        name="get_open_orders",
        description="Get all open orders for the configured wallet or a specific user",
        inputSchema={
            "type": "object",
            "properties": {
                "user": {
                    "type": "string",
                    "description": "User wallet address (optional, defaults to configured wallet)",
                }
            },
            "required": [],
        },
    )
  • Registration of get_open_orders_tool in the MCP server's list_tools decorator method.
    @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,
        ]
  • Core API client method that queries the Hyperliquid API for open orders.
    async def get_open_orders(
        self, user: Optional[str] = None
    ) -> ApiResponse[List[OpenOrder]]:
        """Get all open orders."""
        try:
            payload = {
                "type": "openOrders",
                "user": user or self.config.wallet_address,
            }
    
            response = await self.client.post("/info", json=payload)
            response.raise_for_status()
            return ApiResponse(success=True, data=response.json())
        except Exception as e:
            return ApiResponse(success=False, error=str(e))

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