get_user_fees
Fetch fee structure and rates for a specific Hyperliquid user account, including maker and taker fees.
Instructions
Fetch the fee structure and rates 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 the user's fee structure, including maker and taker fees.
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:217-235 (handler)The main handler function for the 'get_user_fees' tool. It is registered using the @mcp.tool() decorator. The function queries the Hyperliquid SDK's info.user_fees method and returns the result as JSON, with error handling.@mcp.tool() async def get_user_fees(account_address: str, ctx: Context) -> str: """ Fetch the fee structure and rates 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 the user's fee structure, including maker and taker fees. Returns a JSON string with an error message if the query fails. """ try: data = info.user_fees(account_address) return json.dumps(data) except Exception as e: return json.dumps({"error": f"Failed to fetch user fees: {str(e)}"})
- main.py:218-218 (registration)The @mcp.tool() decorator registers the get_user_fees function as an MCP tool.async def get_user_fees(account_address: str, ctx: Context) -> str:
- main.py:219-229 (schema)The docstring provides the input parameters, description, and output format, which FastMCP uses to generate the tool schema.""" Fetch the fee structure and rates 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 the user's fee structure, including maker and taker fees. Returns a JSON string with an error message if the query fails. """