cancel_order
Cancel pending orders on OKX cryptocurrency exchange by specifying the instrument and order ID to manage trading positions.
Instructions
Cancel an incomplete order on OKX
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| instId | Yes | Instrument ID, e.g. BTC-USDT | |
| ordId | No | Order ID. Either ordId or clOrdId is required. If both are passed, ordId will be used | |
| clOrdId | No | Client Order ID as assigned by the client |
Implementation Reference
- mcp_okx/trading.py:148-157 (handler)The handler function for the 'cancel_order' tool, decorated with @mcp.tool which also defines the input schema via Pydantic Fields. It calls the OKX TradeAPI to cancel the specified order.@mcp.tool( title="Cancel an incomplete order", description="Cancel an incomplete order on OKX", ) def cancel_order( instId: str = Field(description="Instrument ID, e.g. BTC-USDT"), ordId: str = Field("", description="Order ID. Either ordId or clOrdId is required. If both are passed, ordId will be used"), clOrdId: str = Field("", description="Client Order ID as assigned by the client"), ): return ACCOUNT.cancel_order(instId=instId, ordId=ordId, clOrdId=clOrdId)
- mcp_okx/__init__.py:26-26 (registration)Registers all trading tools, including 'cancel_order', on the FastMCP server instance by calling the add_tools function from the trading module.trading.add_tools(mcp)
- mcp_okx/trading.py:17-17 (registration)The add_tools function in trading.py where the 'cancel_order' tool is defined and registered when called.def add_tools(mcp: FastMCP):