Skip to main content
Glama
gagarinyury

MCP Bitget Trading Server

by gagarinyury

getOrderBook

Retrieve real-time market depth and order book data for cryptocurrency trading pairs on Bitget exchange to analyze buy/sell pressure and liquidity.

Instructions

Get order book (market depth) for a trading pair

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesTrading pair symbol
depthNoOrder book depth (default: 20)

Implementation Reference

  • MCP tool handler for getOrderBook: parses input with schema, calls BitgetRestClient.getOrderBook, returns JSON response
    case 'getOrderBook': {
      const { symbol, depth = 20 } = GetOrderBookSchema.parse(args);
      const orderBook = await this.bitgetClient.getOrderBook(symbol, depth);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(orderBook, null, 2),
          },
        ],
      } as CallToolResult;
    }
  • src/server.ts:126-136 (registration)
    Tool registration in ListTools handler: defines name, description, and input schema for getOrderBook
      name: 'getOrderBook',
      description: 'Get order book (market depth) for a trading pair',
      inputSchema: {
        type: 'object',
        properties: {
          symbol: { type: 'string', description: 'Trading pair symbol' },
          depth: { type: 'number', description: 'Order book depth (default: 20)' }
        },
        required: ['symbol']
      },
    },
  • Zod schema for validating getOrderBook tool input parameters
    export const GetOrderBookSchema = z.object({
      symbol: z.string().describe('Trading pair symbol (BTCUSDT for spot, BTCUSDT_UMCBL for futures)'),
      depth: z.number().optional().describe('Order book depth (default: 20)')
    });
  • Core implementation of getOrderBook in BitgetRestClient: handles spot/futures detection, caching, API requests to Bitget endpoints, parses order book data
    async getOrderBook(symbol: string, depth: number = 20): Promise<OrderBook> {
      const cacheKey = `orderbook:${symbol}:${depth}`;
      
      // Try cache first
      const cachedOrderBook = orderbookCache.get(cacheKey);
      if (cachedOrderBook) {
        return cachedOrderBook;
      }
    
      let orderBook: OrderBook = {
        symbol: '',
        bids: [],
        asks: [],
        timestamp: 0
      };
      
      if (this.isFuturesSymbol(symbol)) {
        // Futures orderbook
        const futuresSymbol = symbol.includes('_UMCBL') ? symbol : `${symbol}_UMCBL`;
        const response = await this.request<any>('GET', '/api/mix/v1/market/depth', { 
          symbol: futuresSymbol,
          limit: depth.toString()
        });
        
        orderBook = {
          symbol: futuresSymbol,
          bids: response.data?.bids || [],
          asks: response.data?.asks || [],
          timestamp: response.data?.timestamp || Date.now()
        };
      } else {
        // Spot orderbook
        const response = await this.request<any>('GET', '/api/v2/spot/market/orderbook', { 
          symbol, 
          type: 'step0',
          limit: depth.toString()
        });
        
        orderBook = {
          symbol,
          bids: response.data?.bids || [],
          asks: response.data?.asks || [],
          timestamp: response.data?.ts || Date.now()
        };
      }
      
      // Cache the result
      orderbookCache.set(cacheKey, orderBook);
      return orderBook;
    }
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 states it 'gets' data, implying a read operation, but doesn't disclose behavioral traits like whether it requires authentication, has rate limits, returns historical vs real-time data, or what the output format looks like. For a financial data tool with zero annotation coverage, this leaves significant gaps.

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 with zero wasted words. It's front-loaded with the core purpose and appropriately sized for a simple data retrieval tool. Every word earns its place.

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 trading tool. It doesn't cover authentication needs, rate limits, return format, or how it integrates with sibling tools like subscribeToOrderBook. For a tool in a financial context with multiple related siblings, more contextual information is needed.

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 fully documents both parameters (symbol and depth with default). The description adds no additional parameter semantics beyond what's in the schema—it doesn't explain symbol format conventions, depth limitations, or data structure implications. Baseline 3 is appropriate when schema does all the work.

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 resource ('order book (market depth)') with the specific target ('for a trading pair'). It distinguishes from siblings like getPrice or getTicker by specifying market depth data, but doesn't explicitly differentiate from subscribeToOrderBook which provides real-time updates versus this one-time retrieval.

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 guidance is provided on when to use this tool versus alternatives. It doesn't mention when this static order book retrieval is preferred over subscribeToOrderBook for real-time updates, or how it differs from getTicker for price summaries. The description offers no context about 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/gagarinyury/MCP-bitget-trading'

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