Skip to main content
Glama

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
NameRequiredDescriptionDefault
instIdYesInstrument ID, e.g. BTC-USDT
ordIdNoOrder ID. Either ordId or clOrdId is required. If both are passed, ordId will be used
clOrdIdNoClient Order ID as assigned by the client

Implementation Reference

  • 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)
  • 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)
  • The add_tools function in trading.py where the 'cancel_order' tool is defined and registered when called.
    def add_tools(mcp: FastMCP):

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/aahl/mcp-okx'

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