Skip to main content
Glama

unsubscribe_ticker

Stop receiving real-time price updates for a specific cryptocurrency trading pair on the OKX exchange to manage data streams and reduce unnecessary notifications.

Instructions

Unsubscribe from real-time ticker updates for an instrument

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instrumentYesInstrument ID (e.g. BTC-USDT)

Implementation Reference

  • The handler logic for the 'unsubscribe_ticker' tool within the CallToolRequestSchema request handler. It logs the unsubscription, calls the WebSocket client's unsubscribe method with channel 'tickers' and the instrument, and returns a success message.
    if (request.params.name === "unsubscribe_ticker") { console.error( `[WebSocket] Unsubscribing from ticker for ${args.instrument}` ); this.wsClient.unsubscribe("tickers", args.instrument); return { content: [ { type: "text", text: `Successfully unsubscribed from real-time ticker updates for ${args.instrument}.`, }, ], }; }
  • The tool registration in the listTools response, including name, description, and input schema requiring an 'instrument' string.
    { name: "unsubscribe_ticker", description: "Unsubscribe from real-time ticker updates for an instrument", inputSchema: { type: "object", properties: { instrument: { type: "string", description: "Instrument ID (e.g. BTC-USDT)", }, }, required: ["instrument"], }, },
  • The unsubscribe method in OKXWebSocketClient class, which removes the subscription from the set, sends an unsubscribe message to the WebSocket if connected, and logs the action.
    unsubscribe(channel: string, instId: string): void { const key = `${channel}:${instId}`; if (!this.subscriptions.has(key)) { return; // Not subscribed } console.error(`[WebSocket] Unsubscribing from ${channel} for ${instId}`); this.subscriptions.delete(key); if (this.ws && this.ws.readyState === WebSocket.OPEN) { this.ws.send( JSON.stringify({ op: "unsubscribe", args: [ { channel, instId, }, ], }) ); } }
  • src/index.ts:391-395 (registration)
    The validTools array that includes 'unsubscribe_ticker' for validation in the CallToolRequestSchema handler.
    "get_price", "get_candlesticks", "subscribe_ticker", "get_live_ticker", "unsubscribe_ticker",

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/badger3000/okx-mcp-server'

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