Skip to main content
Glama

MCP Bitget Trading Server

by gagarinyury

subscribeToOrderBook

Receive real-time order book updates for specific trading pairs on Bitget cryptocurrency exchange. Specify the symbol and instrument type to monitor market depth and liquidity changes instantly.

Instructions

Subscribe to real-time order book updates

Input Schema

NameRequiredDescriptionDefault
instTypeNoInstrument type (default: SPOT)
symbolYesTrading pair symbol

Input Schema (JSON Schema)

{ "properties": { "instType": { "description": "Instrument type (default: SPOT)", "enum": [ "SPOT", "UMCBL" ], "type": "string" }, "symbol": { "description": "Trading pair symbol", "type": "string" } }, "required": [ "symbol" ], "type": "object" }

Implementation Reference

  • MCP tool handler for subscribeToOrderBook that parses arguments and calls the WebSocket client's subscribe method with channel 'books'
    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)
    Tool registration in the listTools handler, defining the tool name, description, and input schema for subscribeToOrderBook
    { 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'] }, },
  • The subscribe helper method in BitgetWebSocketClient that constructs and sends the WebSocket subscription message (used for order book with channel: 'books')
    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 }); } }

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/gagarinyury/MCP-bitget-trading'

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