Skip to main content
Glama
ethancod1ng

Bybit MCP Server

by ethancod1ng

get_orderbook

Retrieve real-time order book depth data for a specified trading symbol on Bybit, providing bid and ask price levels with quantities to analyze market liquidity and price discovery.

Instructions

Get the order book depth for a trading symbol

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYes
limitNo

Implementation Reference

  • Core handler function that executes the logic for fetching the order book from Bybit API using RestClientV5.
    async getOrderBook(symbol: string, limit: number = 25) {
      try {
        const response = await this.client.getOrderbook({
          category: 'spot',
          symbol: symbol,
          limit: limit
        });
        return response;
      } catch (error) {
        throw new Error(`Failed to get order book for ${symbol}: ${error instanceof Error ? error.message : JSON.stringify(error)}`);
      }
    }
  • MCP server dispatch handler for 'get_orderbook' tool call, delegating to BybitClient.getOrderBook.
    case 'get_orderbook':
      result = await this.client.getOrderBook(
        args.symbol as string,
        args.limit as number
      );
      break;
  • src/tools.ts:24-32 (registration)
    Registration of the 'get_orderbook' tool in the MCP tools array, including name, description, and input schema.
    {
      name: 'get_orderbook',
      description: 'Get the order book depth for a trading symbol',
      inputSchema: {
        type: 'object',
        properties: OrderBookSchema.shape,
        required: ['symbol']
      }
    },
  • Zod schema definition for input validation of the get_orderbook tool (symbol and optional limit).
    export const OrderBookSchema = z.object({
      symbol: z.string().describe('Trading symbol (e.g., BTCUSDT)'),
      limit: z.number().min(1).max(500).optional().describe('Number of entries to return (default: 25)')
    });

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

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