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)}"

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