Skip to main content
Glama
gagarinyury

MCP Bitget Trading Server

by gagarinyury

cancelOrder

Cancel open trading orders on Bitget exchange by specifying order ID and trading pair symbol. This tool manages active positions in cryptocurrency spot and futures markets.

Instructions

Cancel an existing order

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
orderIdYesOrder ID to cancel
symbolYesTrading pair symbol

Implementation Reference

  • MCP server handler for the 'cancelOrder' tool. Parses input arguments using CancelOrderSchema, calls the BitgetRestClient.cancelOrder method, and returns a success or failure message.
    case 'cancelOrder': { const { orderId, symbol } = CancelOrderSchema.parse(args); const success = await this.bitgetClient.cancelOrder(orderId, symbol); return { content: [ { type: 'text', text: success ? `Order ${orderId} cancelled successfully` : `Failed to cancel order ${orderId}`, }, ], } as CallToolResult; }
  • Zod schema defining the input parameters for the cancelOrder tool: orderId and symbol.
    export const CancelOrderSchema = z.object({ orderId: z.string().describe('Order ID to cancel'), symbol: z.string().describe('Trading pair symbol') });
  • src/server.ts:182-192 (registration)
    Registration of the 'cancelOrder' tool in the MCP server's listTools response, including name, description, and input schema matching the Zod schema.
    name: 'cancelOrder', description: 'Cancel an existing order', inputSchema: { type: 'object', properties: { orderId: { type: 'string', description: 'Order ID to cancel' }, symbol: { type: 'string', description: 'Trading pair symbol' } }, required: ['orderId', 'symbol'] }, },
  • Core implementation of cancelOrder in BitgetRestClient. Determines if spot or futures based on symbol, then calls the appropriate private cancel method using Bitget API endpoints.
    async cancelOrder(orderId: string, symbol: string): Promise<boolean> { if (this.isFuturesSymbol(symbol)) { return this.cancelFuturesOrder(orderId, symbol); } else { return this.cancelSpotOrder(orderId, symbol); } } /** * Cancel a spot order */ private async cancelSpotOrder(orderId: string, symbol: string): Promise<boolean> { const response = await this.request<any>('POST', '/api/v2/spot/trade/cancel-order', { orderId, symbol }, true); return response.code === '00000'; } /** * Cancel a futures order */ private async cancelFuturesOrder(orderId: string, symbol: string): Promise<boolean> { // Remove _UMCBL suffix for v1 API const cleanSymbol = symbol.replace('_UMCBL', ''); const response = await this.request<any>('POST', '/api/v2/mix/order/cancel-order', { orderId, symbol: cleanSymbol, productType: 'USDT-FUTURES', marginCoin: 'USDT' }, true); return response.code === '00000'; }

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/gagarinyury/MCP-bitget-trading'

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