Skip to main content
Glama
mixuechu

Binance MCP Server

by mixuechu

cancel_order

Cancel an active trading order on Binance by specifying the trading pair and order ID to manage your cryptocurrency positions.

Instructions

Cancel a specific order.

Args: symbol: The trading pair. order_id: Order ID to cancel.

Returns: Cancellation result.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
symbolYes
order_idYes

Implementation Reference

  • The main handler function for the 'cancel_order' tool, decorated with @mcp.tool() for registration. It cancels a specific order on Binance using the API, authenticating with HMAC signature.
    @mcp.tool()
    def cancel_order(symbol: str, order_id: str) -> Any:
        """
        Cancel a specific order.
    
        Args:
            symbol: The trading pair.
            order_id: Order ID to cancel.
    
        Returns:
            Cancellation result.
        """
        url = "https://api.binance.com/api/v3/order"
        timestamp = int(time.time() * 1000)
        params = {
            "symbol": symbol,
            "orderId": order_id,
            "timestamp": timestamp
        }
        query_string = "&".join([f"{k}={v}" for k, v in params.items()])
        signature = hmac.new(BINANCE_SECRET_KEY.encode(), query_string.encode(), hashlib.sha256).hexdigest()
        params["signature"] = signature
        headers = {"X-MBX-APIKEY": BINANCE_API_KEY}
        response = requests.delete(url, headers=headers, params=params)
        if response.status_code == 200:
            return {"message": f"Order {order_id} canceled"}
        return {"error": response.text}
Behavior2/5

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

No annotations are provided, so the description carries full burden. 'Cancel a specific order' implies a destructive mutation, but lacks details on permissions needed, whether cancellation is reversible, rate limits, error conditions (e.g., if order already filled), or what happens on success/failure. The 'Returns' line is vague ('Cancellation result') without explaining format or meaning.

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 appropriately sized and front-loaded with the core purpose first. The 'Args' and 'Returns' sections add structure without unnecessary verbosity. However, the 'Returns' line is overly vague ('Cancellation result'), which slightly reduces efficiency.

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?

Given a destructive tool with 2 parameters, 0% schema coverage, no annotations, and no output schema, the description is incomplete. It lacks critical behavioral details (e.g., side effects, error handling), parameter specifics (e.g., symbol format), and clear return value explanation. The agent would struggle to use this reliably without external knowledge.

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 0%, so the schema provides no parameter documentation. The description adds basic semantics via the 'Args' section, explaining 'symbol' as 'The trading pair' and 'order_id' as 'Order ID to cancel', which clarifies purpose beyond just names. However, it doesn't specify format (e.g., symbol like 'BTC-USD'), constraints, or examples, leaving gaps.

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 tool's purpose with 'Cancel a specific order' - a specific verb ('Cancel') and resource ('order'). It distinguishes from siblings like 'place_market_order' (creation) and 'get_open_orders' (retrieval). However, it doesn't explicitly mention what distinguishes it from other potential cancellation tools (none exist in siblings).

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?

No guidance on when to use this tool versus alternatives. While siblings include 'get_open_orders' (for viewing orders) and 'place_market_order' (for creating orders), the description doesn't mention prerequisites (e.g., order must exist, be open), timing considerations, or when not to use it. The agent must infer usage from context alone.

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

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