Skip to main content
Glama
ethancod1ng

Bybit MCP Server

by ethancod1ng

cancel_order

Cancel active trading orders on Bybit's platform to manage positions or adjust strategies. Specify product category and symbol to remove pending orders from the exchange.

Instructions

Cancel an existing order (⚠️ WARNING: Affects real orders on mainnet)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryYes
symbolYes
orderIdNo
orderLinkIdNo

Implementation Reference

  • Dispatch handler in handleToolCall method for the 'cancel_order' tool, invoking the BybitClient.cancelOrder method with tool arguments.
    case 'cancel_order':
      result = await this.client.cancelOrder(
        args.category as string,
        args.symbol as string,
        args.orderId as string,
        args.orderLinkId as string
      );
      break;
  • Core implementation of the cancel_order tool logic in BybitClient, performing the actual Bybit API call to cancel the order and handling mainnet warnings.
    async cancelOrder(category: string, symbol: string, orderId?: string, orderLinkId?: string) {
      try {
        if (this.config.environment === 'mainnet') {
          console.error('⚠️  WARNING: Canceling order on MAINNET!');
        }
    
        const response = await this.client.cancelOrder({
          category: category as any,
          symbol: symbol,
          orderId: orderId,
          orderLinkId: orderLinkId
        });
        return response;
      } catch (error) {
        throw new Error(`Failed to cancel order: ${error instanceof Error ? error.message : JSON.stringify(error)}`);
      }
    }
  • src/tools.ts:96-104 (registration)
    Tool registration entry for 'cancel_order' used in listTools response, defining name, description, and input schema.
    {
      name: 'cancel_order',
      description: 'Cancel an existing order (⚠️ WARNING: Affects real orders on mainnet)',
      inputSchema: {
        type: 'object',
        properties: CancelOrderSchema.shape,
        required: ['category', 'symbol']
      }
    },
  • Zod schema defining the input parameters for the cancel_order tool.
    export const CancelOrderSchema = z.object({
      category: z.enum(['spot', 'linear', 'inverse', 'option']).describe('Product type'),
      symbol: z.string().describe('Trading symbol'),
      orderId: z.string().optional().describe('Order ID'),
      orderLinkId: z.string().optional().describe('Order link ID')
    });
Behavior3/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 adds important context about affecting 'real orders on mainnet' (indicating this is a production environment with real consequences), but doesn't disclose other critical behavioral traits like authentication requirements, rate limits, error conditions, or what happens when cancellation succeeds/fails.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately concise with just one sentence that includes both the core purpose and a critical warning. The warning is front-loaded with an emoji for emphasis. However, the structure could be improved by separating the warning into its own sentence for better readability.

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 destructive order cancellation tool with 4 parameters (2 required), 0% schema description coverage, no annotations, and no output schema, the description is insufficient. It covers the high-level purpose and production environment warning but lacks parameter explanations, usage guidance, behavioral details, and information about what the tool returns.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters1/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, meaning none of the 4 parameters have descriptions in the schema. The tool description provides absolutely no information about parameters, their meanings, or how they should be used together. This leaves the agent with no semantic understanding of the required 'category' and 'symbol' parameters or the optional 'orderId' and 'orderLinkId' parameters.

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 ('Cancel') and resource ('an existing order'), providing a specific verb+resource combination. However, it doesn't explicitly differentiate this from sibling tools like 'cancel_all_orders' beyond the singular vs. plural distinction.

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 like 'cancel_all_orders' or when to use it versus other order-related tools. The warning about affecting real orders is helpful but doesn't constitute usage guidance for tool selection.

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/ethancod1ng/bybit-mcp-server'

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