Skip to main content
Glama
t3rmed

Hyperliquid MCP Server

by t3rmed

get_candle_snapshot

Retrieve historical candle data for cryptocurrency trading analysis on Hyperliquid DEX. Specify coin symbol and time interval to access market price history for informed decision-making.

Instructions

Get historical candle data for a specific coin

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
coinYesThe coin symbol (e.g., BTC, ETH, SOL)
endTimeNoEnd time in milliseconds (optional)
intervalYesCandle interval
startTimeNoStart time in milliseconds (optional)

Implementation Reference

  • The main handler function for the 'get_candle_snapshot' tool. It parses input arguments, calls the Hyperliquid client to fetch candle data, formats the response as text, and returns it in MCP content format.
    async def handle_get_candle_snapshot(client: HyperliquidClient, args: Dict[str, Any]) -> Dict[str, Any]:
        """Handle get candle snapshot request."""
        coin = args["coin"]
        interval = args["interval"]
        start_time = args.get("startTime")
        end_time = args.get("endTime")
    
        result = await client.get_candle_snapshot(coin, interval, start_time, end_time)
    
        if not result.success:
            raise ValueError(f"Failed to get candle data for {coin}: {result.error}")
    
        candles = result.data.get("candles", []) if result.data else []
    
        candle_text = "\n".join(
            f"{candle['t']}: O:{candle['o']} H:{candle['h']} L:{candle['l']} C:{candle['c']} V:{candle['v']}"
            for candle in candles
        )
    
        return {
            "content": [
                TextContent(
                    type="text",
                    text=f"Candle data for {coin} ({interval}):\n{candle_text}",
                )
            ]
        }
  • The Tool object definition for 'get_candle_snapshot', including name, description, and detailed input schema with required fields (coin, interval) and optional timestamps.
    get_candle_snapshot_tool = Tool(
        name="get_candle_snapshot",
        description="Get historical candle data for a specific coin",
        inputSchema={
            "type": "object",
            "properties": {
                "coin": {
                    "type": "string",
                    "description": "The coin symbol (e.g., BTC, ETH, SOL)",
                },
                "interval": {
                    "type": "string",
                    "description": "Candle interval",
                    "enum": ["1m", "5m", "15m", "1h", "4h", "1d", "1w", "1M"],
                },
                "startTime": {
                    "type": "number",
                    "description": "Start time in milliseconds (optional)",
                },
                "endTime": {
                    "type": "number",
                    "description": "End time in milliseconds (optional)",
                },
            },
            "required": ["coin", "interval"],
        },
    )
  • Supporting client method in HyperliquidClient that performs the actual API request to Hyperliquid's /info endpoint for candleSnapshot data.
    async def get_candle_snapshot(
        self,
        coin: str,
        interval: str,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
    ) -> ApiResponse[CandleSnapshotResponse]:
        """Get historical candle data."""
        try:
            req_data = {"coin": coin, "interval": interval}
            if start_time is not None:
                req_data["startTime"] = start_time
            if end_time is not None:
                req_data["endTime"] = end_time
    
            payload = {"type": "candleSnapshot", "req": req_data}
    
            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))
  • Registration of the tool handler in the HTTP MCP server's TOOL_HANDLERS dictionary for dispatching tool calls.
    # Map tool names to handlers
    TOOL_HANDLERS = {
        "get_all_mids": handle_get_all_mids,
        "get_l2_book": handle_get_l2_book,
        "get_candle_snapshot": handle_get_candle_snapshot,
        "get_open_orders": handle_get_open_orders,
        "get_user_fills": handle_get_user_fills,
        "get_user_fills_by_time": handle_get_user_fills_by_time,
        "get_portfolio": handle_get_portfolio,
        "place_order": handle_place_order,
        "place_trigger_order": handle_place_trigger_order,
        "cancel_order": handle_cancel_order,
        "cancel_all_orders": handle_cancel_all_orders,
    }
  • Dispatch logic in the stdio MCP server's call_tool method that routes 'get_candle_snapshot' calls to the handler.
    elif name == "get_candle_snapshot":
        result = await handle_get_candle_snapshot(client, args)
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states 'Get historical candle data' which implies a read-only operation, but doesn't cover critical aspects like rate limits, authentication needs, data freshness, or error handling, leaving significant gaps for a tool with market data access.

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 a single, efficient sentence that directly states the tool's function without unnecessary words. It's appropriately sized and front-loaded, making it easy to parse quickly.

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

Completeness2/5

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

Given the complexity of financial data tools, no annotations, and no output schema, the description is insufficient. It lacks details on return format (e.g., data structure, timestamps), error cases, or behavioral constraints, making it incomplete for effective agent use.

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

Parameters3/5

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

Schema description coverage is 100%, so the input schema fully documents all parameters. The description adds no additional meaning beyond implying historical data retrieval, which is already clear from the schema. This meets the baseline for high schema coverage.

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

Purpose4/5

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

The description clearly states the verb 'Get' and the resource 'historical candle data for a specific coin', making the purpose understandable. However, it doesn't distinguish this tool from potential siblings like 'get_all_mids' or 'get_l2_book' that might also provide market data, missing explicit differentiation.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'get_all_mids' and 'get_l2_book' that likely offer different market data, there's no mention of context, prerequisites, or exclusions, leaving usage ambiguous.

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

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