get_user_open_orders
Retrieve all active trading orders for a specific Hyperliquid account, displaying order details including symbol, size, price, and status.
Instructions
Fetch all open orders for a specific user account.
Parameters:
account_address (str): The Hyperliquid account address (e.g., '0xcd5051944f780a621ee62e39e493c489668acf4d').
ctx (Context): The MCP context object for accessing server state.
Returns:
str: A JSON string containing a list of open orders, each with details such as order ID, symbol, size, price,
and status. Returns a JSON string with an error message if the query fails.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account_address | Yes |
Input Schema (JSON Schema)
{
"properties": {
"account_address": {
"title": "Account Address",
"type": "string"
}
},
"required": [
"account_address"
],
"type": "object"
}
Implementation Reference
- main.py:45-62 (handler)Handler function for the 'get_user_open_orders' tool, registered via @mcp.tool() decorator. Fetches open orders using Hyperliquid's info.open_orders() and returns JSON string, with error handling.@mcp.tool() async def get_user_open_orders(account_address: str, ctx: Context) -> str: """ Fetch all open orders for a specific user account. Parameters: account_address (str): The Hyperliquid account address (e.g., '0xcd5051944f780a621ee62e39e493c489668acf4d'). ctx (Context): The MCP context object for accessing server state. Returns: str: A JSON string containing a list of open orders, each with details such as order ID, symbol, size, price, and status. Returns a JSON string with an error message if the query fails. """ try: open_orders = info.open_orders(account_address) return json.dumps(open_orders) except Exception as e: return json.dumps({"error": f"Failed to fetch user open orders: {str(e)}"})