Skip to main content
Glama
laukikk

Alpaca Trading MCP Server

by laukikk

cancel_order

Cancel an open trading order using its unique ID to manage portfolio positions and prevent unwanted executions.

Instructions

Cancel an open order by its ID.

Args: order_id: ID of the order to cancel

Returns: Confirmation of cancellation

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
order_idYes

Implementation Reference

  • The handler function for the 'cancel_order' MCP tool. It is decorated with @mcp.tool() which registers it, takes an order_id string, calls trading_client.cancel_order_by_id(order_id), and returns a success or error message.
    @mcp.tool()
    def cancel_order(order_id: str) -> str:
        """
        Cancel an open order by its ID.
        
        Args:
            order_id: ID of the order to cancel
        
        Returns:
            Confirmation of cancellation
        """
        try:
            trading_client.cancel_order_by_id(order_id)
            return f"Order {order_id} has been successfully canceled."
        except Exception as e:
            return f"Error canceling order {order_id}: {str(e)}"
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral context. It states the action is a cancellation but doesn't disclose critical traits like permission requirements, whether cancellation is reversible, rate limits, or what happens on failure (e.g., if order is already filled).

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 'Args' and 'Returns' sections. Every sentence earns its place with no wasted words, and key information is front-loaded.

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 the tool's complexity (a mutation with no annotations, 0% schema coverage, and no output schema), the description is incomplete. It lacks details on behavioral constraints, error conditions, return value specifics beyond 'confirmation', and how it differs from sibling tools in practice.

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?

Schema description coverage is 0%, so the description must compensate. It adds meaningful context by explaining 'order_id' as 'ID of the order to cancel', clarifying its role beyond the schema's basic string type. However, it doesn't specify format (e.g., numeric, UUID) or sourcing details.

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 verb ('Cancel') and resource ('an open order by its ID'), making the purpose unambiguous. It distinguishes from siblings like 'close_position' by specifying it cancels orders rather than positions, though it doesn't explicitly contrast with all order-placement tools.

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 specify prerequisites (e.g., order must be open), exclusions (e.g., cannot cancel filled orders), or compare with sibling tools like 'close_position' for similar actions.

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/laukikk/alpaca-mcp'

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