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') });

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