Skip to main content
Glama
gagarinyury

MCP Bitget Trading Server

by gagarinyury

subscribeToOrderBook

Subscribe to real-time order book updates for cryptocurrency trading pairs to monitor market depth and price levels.

Instructions

Subscribe to real-time order book updates

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYesTrading pair symbol
instTypeNoInstrument type (default: SPOT)

Implementation Reference

  • Handler for the subscribeToOrderBook MCP tool. Extracts symbol and optional instType from arguments, subscribes to the 'books' WebSocket channel via wsClient, and returns a confirmation message.
    case 'subscribeToOrderBook': {
      const { symbol, instType = 'SPOT' } = args as any;
      this.wsClient.subscribe('books', symbol, instType);
      return {
        content: [
          {
            type: 'text',
            text: `Subscribed to order book updates for ${symbol} (${instType})`,
          },
        ],
      } as CallToolResult;
    }
  • src/server.ts:269-280 (registration)
    Registration of the subscribeToOrderBook tool in the listTools response, including name, description, and input schema definition.
    {
      name: 'subscribeToOrderBook',
      description: 'Subscribe to real-time order book updates',
      inputSchema: {
        type: 'object',
        properties: {
          symbol: { type: 'string', description: 'Trading pair symbol' },
          instType: { type: 'string', enum: ['SPOT', 'UMCBL'], description: 'Instrument type (default: SPOT)' }
        },
        required: ['symbol']
      },
    },
  • Core subscribe helper method in BitgetWebSocketClient. Constructs and sends the WebSocket subscription message (op: 'subscribe') for the given channel ('books' for order book), tracks subscriptions for automatic resubscribe on reconnect.
    subscribe(channel: string, symbol: string, instType: 'SPOT' | 'UMCBL' | 'DMCBL' = 'SPOT'): void {
      const subscription: WSSubscription = {
        op: 'subscribe',
        args: [{
          instType,
          channel,
          instId: symbol
        }]
      };
    
      const subKey = `${instType}:${channel}:${symbol}`;
      this.subscriptions.add(subKey);
    
      if (this.isConnected && this.ws) {
        logger.debug('Subscribing to channel', { channel, symbol, instType });
        this.ws.send(JSON.stringify(subscription));
      } else {
        logger.warn('WebSocket not connected, subscription will be sent on reconnect', { channel, symbol });
      }
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only states what the tool does, not how it behaves. It doesn't disclose that this likely creates a persistent subscription, requires WebSocket connectivity, may have rate limits, or how updates are delivered. The description is minimal and lacks behavioral context.

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 communicates the core purpose without any wasted words. It's appropriately sized for a subscription tool and gets straight to the point.

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?

For a subscription tool with no annotations and no output schema, the description is insufficient. It doesn't explain what happens after subscription (how updates are delivered), whether this requires WebSocket connection first, or what the subscription entails. Given the complexity of real-time data streaming, more context 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. The description adds no additional parameter information beyond what's already in the schema. This meets the baseline expectation when schema coverage is complete.

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 action ('Subscribe to') and resource ('real-time order book updates'), making the purpose immediately understandable. However, it doesn't differentiate from the sibling tool 'subscribeToTicker' or explain what distinguishes order book updates from ticker updates.

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 about when to use this tool versus alternatives like 'getOrderBook' (for one-time retrieval) or 'subscribeToTicker' (for different data type). There's no mention of prerequisites, such as needing an active WebSocket connection via 'connectWebSocket' first.

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