Skip to main content
Glama
ethancod1ng

Binance MCP Server

by ethancod1ng

cancel_order

Cancel a specific trading order on Binance exchange by providing the trading pair symbol and order ID to manage open positions effectively.

Instructions

取消指定订单 - 支持主网和测试网

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
orderIdYes订单ID
symbolYes交易对符号,如 BTCUSDT

Implementation Reference

  • The handler function that executes the cancel_order tool logic: validates input using CancelOrderSchema, calls binanceClient.cancelOrder, and returns the result.
    handler: async (binanceClient: any, args: unknown) => {
      const networkMode = validateAndWarnMainnet();
      
      const input = validateInput(CancelOrderSchema, args);
      validateSymbol(input.symbol);
    
      try {
        const cancelResult = await binanceClient.cancelOrder({
          symbol: input.symbol,
          orderId: input.orderId,
        });
    
        return {
          symbol: cancelResult.symbol,
          origClientOrderId: cancelResult.origClientOrderId,
          orderId: cancelResult.orderId,
          orderListId: cancelResult.orderListId,
          clientOrderId: cancelResult.clientOrderId,
          price: cancelResult.price,
          origQty: cancelResult.origQty,
          executedQty: cancelResult.executedQty,
          cummulativeQuoteQty: cancelResult.cummulativeQuoteQty,
          status: cancelResult.status,
          timeInForce: cancelResult.timeInForce,
          type: cancelResult.type,
          side: cancelResult.side,
          timestamp: Date.now(),
          network: networkMode,
        };
      } catch (error) {
        handleBinanceError(error);
      }
    },
  • The cancel_order tool definition within the tradingTools array, including name, description, inputSchema, and handler reference. This array is exported and used for registration.
    {
      name: 'cancel_order',
      description: '取消指定订单 - 支持主网和测试网',
      inputSchema: {
        type: 'object',
        properties: {
          symbol: {
            type: 'string',
            description: '交易对符号,如 BTCUSDT',
          },
          orderId: {
            type: 'number',
            description: '订单ID',
          },
        },
        required: ['symbol', 'orderId'],
      },
      handler: async (binanceClient: any, args: unknown) => {
        const networkMode = validateAndWarnMainnet();
        
        const input = validateInput(CancelOrderSchema, args);
        validateSymbol(input.symbol);
    
        try {
          const cancelResult = await binanceClient.cancelOrder({
            symbol: input.symbol,
            orderId: input.orderId,
          });
    
          return {
            symbol: cancelResult.symbol,
            origClientOrderId: cancelResult.origClientOrderId,
            orderId: cancelResult.orderId,
            orderListId: cancelResult.orderListId,
            clientOrderId: cancelResult.clientOrderId,
            price: cancelResult.price,
            origQty: cancelResult.origQty,
            executedQty: cancelResult.executedQty,
            cummulativeQuoteQty: cancelResult.cummulativeQuoteQty,
            status: cancelResult.status,
            timeInForce: cancelResult.timeInForce,
            type: cancelResult.type,
            side: cancelResult.side,
            timestamp: Date.now(),
            network: networkMode,
          };
        } catch (error) {
          handleBinanceError(error);
        }
      },
    },
  • Zod schema (CancelOrderSchema) used for input validation in the cancel_order handler.
    export const CancelOrderSchema = z.object({
      symbol: z.string().describe('交易对符号'),
      orderId: z.number().describe('订单ID'),
    });
  • src/server.ts:41-50 (registration)
    Registers all tools, including those from tradingTools (containing cancel_order), into the server's tools Map by name.
    private setupTools(): void {
      const allTools = [
        ...marketDataTools,
        ...accountTools,
        ...tradingTools,
      ];
    
      for (const tool of allTools) {
        this.tools.set(tool.name, tool);
      }
  • TypeScript interface for the Binance cancel order response, used in handler return type.
    export interface BinanceCancelOrderResponse {
      symbol: string;
      origClientOrderId: string;
      orderId: number;
      orderListId: number;
      clientOrderId: string;
      price: string;
      origQty: string;
      executedQty: string;
      cummulativeQuoteQty: string;
      status: OrderStatus;
      timeInForce: TimeInForce;
      type: OrderType;
      side: OrderSide;
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. While it states the action is cancellation and mentions network support, it doesn't describe what happens when an order is canceled (partial fills, fees, confirmation), whether cancellation is immediate or queued, error conditions, or authentication requirements. For a destructive operation with zero annotation coverage, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise - a single sentence that communicates the core purpose and network scope. There's no wasted language or redundancy. However, for a destructive operation, some might argue it's too brief given the lack of behavioral details elsewhere.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a destructive operation with no annotations and no output schema, the description is incomplete. It doesn't explain what happens after cancellation, what the response contains, error conditions, or important behavioral constraints. The network scope information is helpful but doesn't compensate for the significant gaps in understanding this tool's behavior.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, with both parameters clearly documented in the schema. The description adds no additional parameter information beyond what's already in the schema. The baseline score of 3 is appropriate when the schema does all the parameter documentation work.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('取消指定订单' - cancel specified order) and resource (orders), making the purpose immediately understandable. It adds network scope information ('支持主网和测试网' - supports mainnet and testnet) which provides useful context. However, it doesn't explicitly differentiate from its sibling 'cancel_all_orders' beyond the 'specified' vs 'all' distinction implied in the tool names.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (like needing an open order to cancel), when to use 'cancel_all_orders' instead, or any constraints on which orders can be canceled. The network scope information is helpful but doesn't constitute usage guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/binance-mcp-server'

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