get_user_sub_accounts
Retrieve sub-accounts linked to a Hyperliquid user account by providing the account address, returning structured data for account management.
Instructions
Fetch the sub-accounts associated with 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 sub-accounts and their details.
Returns a JSON string with an error message if the query fails.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account_address | Yes |
Implementation Reference
- main.py:319-336 (handler)The handler function for the 'get_user_sub_accounts' tool, decorated with @mcp.tool() for registration. It fetches sub-accounts for the given account_address using the Hyperliquid Info API and returns the data as JSON or an error message.@mcp.tool() async def get_user_sub_accounts(account_address: str, ctx: Context) -> str: """ Fetch the sub-accounts associated with 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 sub-accounts and their details. Returns a JSON string with an error message if the query fails. """ try: data = info.query_sub_accounts(account_address) return json.dumps(data) except Exception as e: return json.dumps({"error": f"Failed to fetch user sub accounts: {str(e)}"})