cancelOrder
Cancel a specific cryptocurrency trading order by providing account details, order ID, and trading symbol. Integrates with CCXT MCP Server for exchange API connectivity.
Instructions
Cancel an existing order using a configured account
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accountName | Yes | Account name defined in the configuration file (e.g., 'bybit_main') | |
| id | Yes | Order ID to cancel | |
| params | No | Additional exchange-specific parameters | |
| symbol | Yes | Trading symbol (e.g., 'BTC/USDT') |
Implementation Reference
- src/tools/order-tools.ts:118-147 (handler)The handler function that retrieves the exchange instance and calls exchange.cancelOrder(id, symbol, params) to cancel the order, returning the result or error.async ({ accountName, id, symbol, params }) => { try { const exchange = ccxtServer.getExchangeInstance(accountName); // getExchangeInstance가 성공하면 인증은 보장됨 const result = await exchange.cancelOrder(id, symbol, params); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error canceling order for account '${accountName}': ${ (error as Error).message }`, }, ], isError: true, }; } },
- src/tools/order-tools.ts:105-117 (schema)Zod schema defining the input parameters for the cancelOrder tool: accountName, id, symbol, and optional params.{ accountName: z .string() .describe( "Account name defined in the configuration file (e.g., 'bybit_main')" ), id: z.string().describe("Order ID to cancel"), symbol: z.string().describe("Trading symbol (e.g., 'BTC/USDT')"), params: z .record(z.any()) .optional() .describe("Additional exchange-specific parameters"), },
- src/tools/order-tools.ts:102-148 (registration)Registers the cancelOrder tool on the MCP server using server.tool(), including name, description, input schema, and handler function.server.tool( "cancelOrder", "Cancel an existing order using a configured account", { accountName: z .string() .describe( "Account name defined in the configuration file (e.g., 'bybit_main')" ), id: z.string().describe("Order ID to cancel"), symbol: z.string().describe("Trading symbol (e.g., 'BTC/USDT')"), params: z .record(z.any()) .optional() .describe("Additional exchange-specific parameters"), }, async ({ accountName, id, symbol, params }) => { try { const exchange = ccxtServer.getExchangeInstance(accountName); // getExchangeInstance가 성공하면 인증은 보장됨 const result = await exchange.cancelOrder(id, symbol, params); return { content: [ { type: "text", text: JSON.stringify(result, null, 2), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error canceling order for account '${accountName}': ${ (error as Error).message }`, }, ], isError: true, }; } }, );