Skip to main content
Glama
badger3000

OKX MCP Server

by badger3000

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

  • Main execution logic for the unsubscribe_ticker tool: logs the action, calls the WebSocket client's unsubscribe method for the 'tickers' channel, and returns a success confirmation 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}.`,
          },
        ],
      };
    }
  • Input schema definition for the unsubscribe_ticker tool, specifying the required 'instrument' parameter.
    {
      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"],
      },
    },
  • src/index.ts:390-396 (registration)
    Registration of unsubscribe_ticker as a valid tool name in the dispatch logic for CallToolRequestSchema.
    const validTools = [
      "get_price",
      "get_candlesticks",
      "subscribe_ticker",
      "get_live_ticker",
      "unsubscribe_ticker",
    ];
  • Helper method in OKXWebSocketClient class that performs the actual WebSocket unsubscription, used by the tool handler.
    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,
              },
            ],
          })
        );
      }
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action but doesn't describe what 'unsubscribe' entails—whether it stops updates immediately, affects other users, requires specific permissions, or has side effects. This leaves critical behavioral traits undocumented for a mutation tool.

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, clear sentence with no wasted words. It's front-loaded with the core action and resource, making it easy to parse quickly. Every part of the sentence contributes directly to understanding the tool's purpose.

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 mutation tool with no annotations and no output schema, the description is incomplete. It lacks information about what happens after unsubscribing (e.g., confirmation, error handling), behavioral details, and how it integrates with sibling tools. This leaves significant gaps for an agent to use it correctly in context.

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?

The schema description coverage is 100%, with the single parameter 'instrument' well-documented in the schema. The description adds no additional semantic context about the parameter, such as format examples beyond what's in the schema or constraints like valid instrument types. This meets the baseline for high schema coverage.

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 ('Unsubscribe from') and the resource ('real-time ticker updates for an instrument'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from its sibling 'subscribe_ticker' beyond the obvious opposite action, missing an opportunity to clarify scope or relationship.

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 on when to use this tool versus alternatives or prerequisites. It doesn't mention if it should only be called after subscribing via 'subscribe_ticker', what happens if unsubscribing from a non-subscribed instrument, or any context about its role relative to sibling tools like 'get_live_ticker'.

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

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