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
| Name | Required | Description | Default |
|---|---|---|---|
| symbol | Yes | Trading pair symbol | |
| instType | No | Instrument 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'] }, },
- src/server.ts:505-516 (handler)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; }
- src/api/websocket-client.ts:110-129 (helper)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 }); } }