Skip to main content
Glama
laukikk

Alpaca Trading MCP Server

by laukikk

cancel_order

Cancel an open trading order by its ID to manage 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 main handler function for the 'cancel_order' tool. Decorated with @mcp.tool() which registers it in the MCP server. Takes order_id as input, calls trading_client.cancel_order_by_id() to perform the cancellation, 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