Skip to main content
Glama
ethancod1ng

Bybit MCP Server

by ethancod1ng

cancel_all_orders

Cancel all active trading orders for a specific symbol or product category on Bybit. Use this tool to clear pending orders and manage your trading positions effectively.

Instructions

Cancel all orders for a symbol or category (⚠️ WARNING: Affects real orders on mainnet)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryYesProduct type
symbolNoTrading symbol (optional, if not provided cancels all orders in category)

Implementation Reference

  • Dispatches the 'cancel_all_orders' tool call to the BybitClient's cancelAllOrders method with category and optional symbol arguments.
    case 'cancel_all_orders':
      result = await this.client.cancelAllOrders(
        args.category as string,
        args.symbol as string
      );
      break;
  • src/tools.ts:105-123 (registration)
    Registers the 'cancel_all_orders' tool including its name, description, and input schema definition.
    {
      name: 'cancel_all_orders',
      description: 'Cancel all orders for a symbol or category (⚠️ WARNING: Affects real orders on mainnet)',
      inputSchema: {
        type: 'object',
        properties: {
          category: {
            type: 'string',
            enum: ['spot', 'linear', 'inverse', 'option'],
            description: 'Product type'
          },
          symbol: {
            type: 'string',
            description: 'Trading symbol (optional, if not provided cancels all orders in category)'
          }
        },
        required: ['category']
      }
    }
  • Implements the core logic for canceling all orders by calling the Bybit API's cancelAllOrders endpoint, with mainnet warning.
    async cancelAllOrders(category: string, symbol?: string) {
      try {
        if (this.config.environment === 'mainnet') {
          console.error('⚠️  WARNING: Canceling ALL orders on MAINNET!');
        }
    
        const response = await this.client.cancelAllOrders({
          category: category as any,
          symbol: symbol
        });
        return response;
      } catch (error) {
        throw new Error(`Failed to cancel all orders: ${error instanceof Error ? error.message : JSON.stringify(error)}`);
      }
    }

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