Skip to main content
Glama

get_orderbook

Retrieve real-time orderbook data for specified symbols and categories on Bybit. Input symbol, limit, and category to access market depth and trading insights instantly.

Instructions

Get orderbook data
:parameter
    symbol: Symbol (e.g., BTCUSDT)
    limit: Number of orderbook entries to retrieve
    category: Category (spot, linear, inverse, etc.)

Args:
    category: Category (spot, linear, inverse, etc.)
    symbol (str): Symbol (e.g., BTCUSDT)
    limit (int): Number of orderbook entries to retrieve

Returns:
    Dict: Orderbook data

Example:
    get_orderbook("spot", "BTCUSDT", 10)

Reference:
    https://bybit-exchange.github.io/docs/v5/market/orderbook

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryYesCategory (spot, linear, inverse, etc.)
limitNoNumber of orderbook entries to retrieve
symbolYesSymbol (e.g., BTCUSDT)

Implementation Reference

  • MCP tool handler for 'get_orderbook'. Decorated with @mcp.tool(), defines input schema using Field annotations, fetches orderbook data via bybit_service, handles API errors and exceptions.
    @mcp.tool()
    def get_orderbook(
        category: str = Field(description="Category (spot, linear, inverse, etc.)"),
        symbol: str = Field(description="Symbol (e.g., BTCUSDT)"),
        limit: int = Field(default=50, description="Number of orderbook entries to retrieve")
    ) -> Dict:
        """
        Get orderbook data
        :parameter
            symbol: Symbol (e.g., BTCUSDT)
            limit: Number of orderbook entries to retrieve
            category: Category (spot, linear, inverse, etc.)
    
        Args:
            category: Category (spot, linear, inverse, etc.)
            symbol (str): Symbol (e.g., BTCUSDT)
            limit (int): Number of orderbook entries to retrieve
    
        Returns:
            Dict: Orderbook data
    
        Example:
            get_orderbook("spot", "BTCUSDT", 10)
    
        Reference:
            https://bybit-exchange.github.io/docs/v5/market/orderbook
        """
        try:
            result = bybit_service.get_orderbook(category, symbol, limit)
            if result.get("retCode") != 0:
                logger.error(f"Failed to get orderbook: {result.get('retMsg')}")
                return {"error": result.get("retMsg")}
            return result
        except Exception as e:
            logger.error(f"Failed to get orderbook: {e}", exc_info=True)
            return {"error": str(e)}
  • Input schema definitions using Pydantic Field for the get_orderbook tool parameters.
    category: str = Field(description="Category (spot, linear, inverse, etc.)"),
    symbol: str = Field(description="Symbol (e.g., BTCUSDT)"),
    limit: int = Field(default=50, description="Number of orderbook entries to retrieve")
  • BybitService helper method that wraps the pybit client's get_orderbook call.
    def get_orderbook(self, category: str, symbol: str, limit: int = 50) -> Dict:
        """
        Get orderbook data
    
        Args:
            category (str): Category (spot, linear, inverse, etc.)
            symbol (str): Symbol (e.g., BTCUSDT)
            limit (int): Number of orderbook entries to retrieve
    
        Returns:
            Dict: Orderbook data
        """
        return self.client.get_orderbook(
            category=category,
            symbol=symbol,
            limit=limit
        )
  • src/server.py:54-54 (registration)
    Registration of the get_orderbook tool using the @mcp.tool() decorator.
    @mcp.tool()
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions 'Get orderbook data' and includes an example and reference link, but lacks details on behavioral traits such as rate limits, authentication needs, error handling, or whether it's a real-time or cached snapshot. The example and reference add some context but don't fully disclose operational behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is poorly structured with redundant sections (':parameter' and 'Args:' list the same info), an example, and a reference link. It's not front-loaded effectively, and sentences like 'Get orderbook data' are too brief, while repetition wastes space. It could be streamlined to improve clarity and efficiency.

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 no annotations and no output schema, the description is incomplete for a tool with 3 parameters. It lacks details on return values (beyond 'Dict: Orderbook data'), error cases, or behavioral context like pagination or data freshness. The example and reference help but don't compensate for missing operational guidance.

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 schema already documents all parameters (category, symbol, limit) with descriptions. The description repeats parameter info in the ':parameter' section and 'Args:', adding no new meaning beyond the schema. Baseline is 3 since the schema does the heavy lifting, but no extra value is provided.

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

Purpose3/5

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

The description states 'Get orderbook data' which clearly indicates a retrieval operation, but it's vague about what specific data is returned (e.g., bids/asks, depth levels). It distinguishes from siblings like 'get_tickers' or 'get_kline' by focusing on orderbook data, but lacks specificity about the verb+resource combination beyond the basic action.

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?

No explicit guidance on when to use this tool versus alternatives like 'get_tickers' for price data or 'get_instruments_info' for instrument details. The description implies usage for orderbook retrieval but doesn't specify contexts, prerequisites, or exclusions, leaving the agent to infer based on tool names alone.

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

Related 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/dlwjdtn535/mcp-bybit-server'

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