Skip to main content
Glama

cancelOrder

Cancel an existing cryptocurrency trading order on supported exchanges using account credentials, order ID, and trading symbol.

Instructions

Cancel an existing order using a configured account

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountNameYesAccount name defined in the configuration file (e.g., 'bybit_main')
idYesOrder ID to cancel
symbolYesTrading symbol (e.g., 'BTC/USDT')
paramsNoAdditional exchange-specific parameters

Implementation Reference

  • The core handler function that executes the cancelOrder tool. Retrieves the CCXT exchange instance for the given accountName and invokes exchange.cancelOrder(id, symbol, params). Handles errors and returns formatted content.
    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, }; } },
  • Zod input schema defining parameters for the cancelOrder tool: accountName (string), id (string), symbol (string), optional params (record).
    { 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"), },
  • Direct registration of the 'cancelOrder' tool on the MCP server via 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, }; } }, );
  • src/server.ts:373-373 (registration)
    Invocation of registerOrderTools(server, ccxtServer) in CcxtMcpServer.registerTools(), which registers the cancelOrder tool among other order tools.
    registerOrderTools(this.server, this);
  • Helper method used by the cancelOrder handler to retrieve the pre-authenticated CCXT Exchange instance for the specified accountName from loaded configuration.
    getExchangeInstance(accountName: string): Exchange { const instance = this.exchangeInstances[accountName]; if (!instance) { console.error( `No pre-loaded exchange instance found for account name: ${accountName}`, ); // Consider listing available account names: Object.keys(this.exchangeInstances).join(', ') throw new Error( `Account configuration not found or failed to load for: ${accountName}`, ); } return instance; }

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/lazy-dinosaur/ccxt-mcp'

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