Skip to main content
Glama
kukapay

hyperliquid-info-mcp

get_user_trade_history

Retrieve trade history for a Hyperliquid account to analyze transaction patterns and track performance over time.

Instructions

Fetch the trade fill history 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 trade fills, each with details such as symbol, size, price, timestamp,
        and trade ID. Returns a JSON string with an error message if the query fails.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_addressYes

Implementation Reference

  • main.py:83-101 (handler)
    The handler function decorated with @mcp.tool() implements the get_user_trade_history tool. It takes an account_address and ctx, calls info.user_fills(account_address) from the Hyperliquid SDK to fetch trade fills, and returns them as JSON or an error message. The docstring provides input/output schema details.
    # Tool: Get user trade history
    @mcp.tool()
    async def get_user_trade_history(account_address: str, ctx: Context) -> str:
        """
        Fetch the trade fill history 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 trade fills, each with details such as symbol, size, price, timestamp,
                and trade ID. Returns a JSON string with an error message if the query fails.
        """
        try:
            fills = info.user_fills(account_address)
            return json.dumps(fills)
        except Exception as e:
            return json.dumps({"error": f"Failed to fetch user fills: {str(e)}"})
  • main.py:14-14 (helper)
    Global 'info' instance from hyperliquid.info.Info used by the tool to call user_fills(account_address).
    info = Info(constants.MAINNET_API_URL, skip_ws=True)  # Initialize Info for mainnet
  • A prompt function 'analyze_positions' that instructs to use get_user_trade_history among other tools for analysis.
    return [
        base.UserMessage(f"Please analyze the trading positions for account {account_address}:"),
        base.UserMessage("Use the get_user_state, get_user_open_orders, get_user_trade_history, get_user_funding_history, and get_user_fees tools to fetch data."),
        base.AssistantMessage(
            "I'll analyze the user's trading positions, open orders, trade history, funding payments, and fees to provide insights on risk and performance."
        )
    ]
Behavior3/5

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

With no annotations provided, the description carries the full burden. It discloses that it fetches historical data (implied read-only) and mentions potential failure with error messages, but lacks details on rate limits, authentication needs, or data freshness. It adds some behavioral context but not comprehensively.

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 well-structured and front-loaded with the core purpose, followed by clear parameter and return sections. Every sentence adds value without redundancy, making it efficient and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, 0% schema coverage, and no output schema, the description compensates well by explaining the parameter, return format, and error handling. However, it could be more complete by detailing the 'ctx' parameter or providing more behavioral context for a tool with potential complexity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds significant meaning beyond the input schema, which has 0% coverage. It explains that 'account_address' is a Hyperliquid account address with an example format, clarifying the parameter's purpose and expected value, though it does not detail the 'ctx' parameter beyond naming it.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Fetch') and resource ('trade fill history for a specific user account'), distinguishing it from sibling tools like get_user_funding_history or get_user_open_orders by focusing on trade fills rather than other user data.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage context by specifying 'for a specific user account' but does not explicitly state when to use this tool versus alternatives like get_user_state or get_user_fees, nor does it mention prerequisites or exclusions.

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/kukapay/hyperliquid-info-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server