Skip to main content
Glama
samklein952-hub

Hyperliquid MCP Server

get_orderbook

Retrieve real-time bid and ask price levels for perpetual markets on Hyperliquid exchange to analyze market depth and liquidity.

Instructions

Get the orderbook (bids and asks) for a perpetual market

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesMarket symbol (e.g. BTC, ETH)
depthNoNumber of price levels (default 10)

Implementation Reference

  • The main handler implementation of get_orderbook. Retrieves the L2 orderbook snapshot from Hyperliquid API, extracts bid/ask levels, and formats them into a clean dictionary response with price and size for each level.
    def get_orderbook(self, symbol: str, depth: int = 10) -> dict[str, Any]:
        """Get orderbook for a market."""
        book = self.info.l2_snapshot(symbol.upper())
        levels = book.get("levels", [[], []])
        bids = [{"price": b["px"], "size": b["sz"]} for b in levels[0][:depth]]
        asks = [{"price": a["px"], "size": a["sz"]} for a in levels[1][:depth]]
        return {"symbol": symbol.upper(), "bids": bids, "asks": asks}
  • Registration of the get_orderbook tool in the MCP server. Defines the tool name, description, and input schema with symbol (required string) and depth (optional integer with default 10) parameters.
    Tool(
        name="get_orderbook",
        description="Get the orderbook (bids and asks) for a perpetual market",
        inputSchema={
            "type": "object",
            "properties": {
                "symbol": {"type": "string", "description": "Market symbol (e.g. BTC, ETH)"},
                "depth": {"type": "integer", "description": "Number of price levels (default 10)", "default": 10},
            },
            "required": ["symbol"],
        },
    ),
  • Dispatch handler that routes get_orderbook tool calls to the client method. Extracts symbol and optional depth arguments and calls client.get_orderbook() with the appropriate parameters.
    case "get_orderbook":
        return client.get_orderbook(args["symbol"], args.get("depth", 10))
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It implies a read-only operation via 'Get' but fails to disclose latency characteristics, authentication requirements, error handling for invalid symbols, or data freshness guarantees.

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 of nine words that immediately communicates the core function without redundancy or filler content.

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

Completeness3/5

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

Given the simple 2-parameter schema with complete coverage and no output schema, the description is minimally adequate. It mentions 'bids and asks' hinting at return structure, but lacks explicit return value documentation or behavioral context expected when no output schema is present.

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 coverage is 100%, so the baseline is 3. The description adds slight value by specifying 'perpetual market' context for the symbol parameter, though it does not elaborate on depth behavior beyond the schema's default value description.

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 tool retrieves the orderbook with specific mention of 'bids and asks' for a 'perpetual market'. It distinguishes from siblings like get_account_info or get_positions by specifying the resource type, though it could explicitly differentiate from get_market_info.

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 like get_market_info, nor does it mention prerequisites such as valid market symbols or rate limit considerations.

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

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