Skip to main content
Glama
ethancod1ng

Binance MCP Server

by ethancod1ng

cancel_all_orders

Cancel all open orders for a specific trading pair on Binance exchange to manage positions and reduce exposure.

Instructions

取消指定交易对所有挂单 - 支持主网和测试网

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYes交易对符号,如 BTCUSDT

Implementation Reference

  • The handler function that executes the cancel_all_orders tool: validates input, calls binanceClient.cancelOpenOrders(symbol), processes results into cancelledOrders array, and returns formatted response including count and network mode.
    handler: async (binanceClient: any, args: unknown) => {
      const networkMode = validateAndWarnMainnet();
      
      const input = validateInput(CancelAllOrdersSchema, args);
      validateSymbol(input.symbol);
    
      try {
        const cancelResults = await binanceClient.cancelOpenOrders({
          symbol: input.symbol,
        });
    
        return {
          symbol: input.symbol,
          cancelledOrders: Array.isArray(cancelResults) ? cancelResults.map((result: any) => ({
            symbol: result.symbol,
            origClientOrderId: result.origClientOrderId,
            orderId: result.orderId,
            orderListId: result.orderListId,
            clientOrderId: result.clientOrderId,
            price: result.price,
            origQty: result.origQty,
            executedQty: result.executedQty,
            cummulativeQuoteQty: result.cummulativeQuoteQty,
            status: result.status,
            timeInForce: result.timeInForce,
            type: result.type,
            side: result.side,
          })) : [cancelResults],
          count: Array.isArray(cancelResults) ? cancelResults.length : 1,
          timestamp: Date.now(),
          network: networkMode,
        };
      } catch (error) {
        handleBinanceError(error);
      }
    },
  • Tool registration as part of the tradingTools export array, defining name, description, inputSchema for MCP, and handler reference.
    {
      name: 'cancel_all_orders',
      description: '取消指定交易对所有挂单 - 支持主网和测试网',
      inputSchema: {
        type: 'object',
        properties: {
          symbol: {
            type: 'string',
            description: '交易对符号,如 BTCUSDT',
          },
        },
        required: ['symbol'],
      },
      handler: async (binanceClient: any, args: unknown) => {
        const networkMode = validateAndWarnMainnet();
        
        const input = validateInput(CancelAllOrdersSchema, args);
        validateSymbol(input.symbol);
    
        try {
          const cancelResults = await binanceClient.cancelOpenOrders({
            symbol: input.symbol,
          });
    
          return {
            symbol: input.symbol,
            cancelledOrders: Array.isArray(cancelResults) ? cancelResults.map((result: any) => ({
              symbol: result.symbol,
              origClientOrderId: result.origClientOrderId,
              orderId: result.orderId,
              orderListId: result.orderListId,
              clientOrderId: result.clientOrderId,
              price: result.price,
              origQty: result.origQty,
              executedQty: result.executedQty,
              cummulativeQuoteQty: result.cummulativeQuoteQty,
              status: result.status,
              timeInForce: result.timeInForce,
              type: result.type,
              side: result.side,
            })) : [cancelResults],
            count: Array.isArray(cancelResults) ? cancelResults.length : 1,
            timestamp: Date.now(),
            network: networkMode,
          };
        } catch (error) {
          handleBinanceError(error);
        }
      },
    },
  • Zod schema used for input validation in the handler: requires 'symbol' as string.
    export const CancelAllOrdersSchema = z.object({
      symbol: z.string().describe('交易对符号'),
    });
  • src/server.ts:41-51 (registration)
    Server setup where tradingTools (including cancel_all_orders) are spread into allTools and registered into the MCP 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 type inferred from CancelAllOrdersSchema for input typing.
    export type CancelAllOrdersInput = z.infer<typeof CancelAllOrdersSchema>;
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 '取消' (cancel) clearly indicates a destructive write operation, the description lacks critical behavioral details: whether this requires specific permissions, if it's irreversible, what happens on partial failures, rate limits, or response format. The mention of network types adds minimal context beyond the core action.

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 a single, efficient sentence that front-loads the core functionality. The network support information is relevant but could be more integrated. There's no wasted verbiage, though it could benefit from slightly more structured presentation of key information.

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 tool with no annotations and no output schema, the description is insufficiently complete. It doesn't explain what happens after cancellation (confirmation? error handling?), doesn't mention authentication requirements, and provides minimal behavioral context. The sibling tool context suggests this is part of a trading API, but the description doesn't leverage this context adequately.

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 the single parameter 'symbol' well-documented in the schema. The description adds no additional parameter semantics beyond what's already in the schema ('交易对符号' appears in both). With complete schema coverage, the baseline is 3 even without extra parameter information in the description.

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 ('取消' meaning 'cancel') and target resource ('所有挂单' meaning 'all pending orders') with scope ('指定交易对' meaning 'specified trading pair'). It distinguishes from the sibling 'cancel_order' by specifying it cancels ALL orders rather than individual ones. However, it doesn't explicitly mention the platform context (cryptocurrency exchange) which would make it fully specific.

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

Usage Guidelines3/5

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

The description implies usage context by mentioning '主网和测试网' (mainnet and testnet), suggesting it works on both production and testing environments. However, it provides no explicit guidance on when to use this vs the sibling 'cancel_order' tool, nor does it mention prerequisites like authentication or account status requirements.

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