Skip to main content
Glama

cancel_order

Cancel open trading orders on the Alpaca platform using order ID. This MonteWalk MCP server tool helps manage active positions by removing pending trades.

Instructions

Cancels a specific open order.

Args:
    order_id: The Alpaca order ID to cancel
    
Returns:
    Confirmation message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
order_idYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Main MCP tool handler: cancels order via broker and returns user-friendly status message.
    def cancel_order(order_id: str) -> str:
        """
        Cancels a specific open order.
        
        Args:
            order_id: The Alpaca order ID to cancel
            
        Returns:
            Confirmation message
        """
        if broker is None:
            return "ERROR: Alpaca broker not initialized."
        
        try:
            logger.info(f"Cancelling order: {order_id}")
            broker.cancel_order(order_id)
            logger.info(f"Order {order_id} cancelled successfully")
            return f"✅ Order {order_id} cancelled successfully"
        except Exception as e:
            logger.error(f"Cancel order failed: {e}", exc_info=True)
            return f"ERROR: Failed to cancel order - {str(e)}"
  • Broker class method that performs the actual API call to cancel_order_by_id on Alpaca TradingClient.
    def cancel_order(self, order_id: str) -> bool:
        """
        Cancel a pending order.
        
        Args:
            order_id: Order ID to cancel
            
        Returns:
            True if successful
        """
        try:
            self.trading_client.cancel_order_by_id(order_id)
            logger.info(f"Order {order_id} cancelled")
            return True
        except Exception as e:
            logger.error(f"Failed to cancel order {order_id}: {e}")
            raise
  • server.py:375-378 (registration)
    Registration of cancel_order (and related execution tools) as MCP tools via register_tools helper.
    register_tools(
        [place_order, cancel_order, get_positions, flatten, get_order_history],
        "Execution"
    )
  • app.py:288-288 (registration)
    Tool grouping/listing in Gradio app's tools_map for UI toolbox (MCP server also enabled).
    "Execution": [place_order, cancel_order, get_positions, flatten, get_order_history],
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool cancels an order, implying a destructive mutation, but does not cover critical aspects like required permissions, rate limits, error conditions (e.g., if order is already canceled), or what happens upon success. This is a significant gap for a mutation tool with zero annotation coverage.

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

Conciseness5/5

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

The description is highly concise and well-structured: a clear purpose statement followed by brief, formatted sections for Args and Returns. Every sentence earns its place, with no redundant information, making it easy to scan and understand quickly.

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

Completeness3/5

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

Given the tool's complexity (a destructive mutation with 1 parameter) and the presence of an output schema (which handles return values), the description is moderately complete. It covers the basic purpose and parameter semantics but lacks behavioral details like error handling or usage context. With no annotations and incomplete behavioral transparency, it meets minimum viability but has clear gaps.

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

Parameters4/5

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

The description adds meaningful context for the single parameter: 'order_id: The Alpaca order ID to cancel.' This clarifies the parameter's purpose and format (Alpaca-specific ID), which is valuable since schema description coverage is 0% (no schema descriptions). With 0% coverage, the description compensates well, though it could specify ID format or constraints for a perfect score.

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: 'Cancels a specific open order.' It specifies the verb ('cancels') and resource ('a specific open order'), making the action unambiguous. However, it does not explicitly differentiate from sibling tools like 'place_order' or 'get_order_history', which would require a 5.

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 does not mention prerequisites (e.g., order must be open), exclusions (e.g., cannot cancel filled orders), or refer to sibling tools like 'place_order' for creating orders or 'get_order_history' for checking status. This leaves usage context implied but not stated.

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/N-lia/MonteWalk'

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