Skip to main content
Glama
gagarinyury

MCP Bitget Trading Server

by gagarinyury

subscribeToTicker

Subscribe to real-time price updates for cryptocurrency trading pairs on Bitget exchange to monitor market movements.

Instructions

Subscribe to real-time ticker updates

Input Schema

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

Implementation Reference

  • src/server.ts:257-268 (registration)
    Registration of the 'subscribeToTicker' tool in the MCP server's listTools handler, including name, description, and input schema definition.
    { name: 'subscribeToTicker', description: 'Subscribe to real-time ticker 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'] }, },
  • Handler implementation for the 'subscribeToTicker' tool in the MCP server's CallToolRequestSchema switch statement. Parses arguments and delegates to WebSocket client's subscribe method.
    case 'subscribeToTicker': { const { symbol, instType = 'SPOT' } = args as any; this.wsClient.subscribe('ticker', symbol, instType); return { content: [ { type: 'text', text: `Subscribed to ticker updates for ${symbol} (${instType})`, }, ], } as CallToolResult; }
  • Core subscribe method in BitgetWebSocketClient that constructs and sends the WebSocket subscription message for the ticker channel to Bitget exchange.
    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 }); } }

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