Skip to main content
Glama
Habinar

MCP Paradex Server

by Habinar

paradex_cancel_orders

Cancel pending orders to manage trading exposure, adjust strategies, or respond to market changes. Remove specific orders or clear all orders when needed.

Instructions

Cancel pending orders to manage exposure or adjust your trading strategy.

Use this tool when you need to:
- Remove stale limit orders that are no longer desirable
- Quickly reduce market exposure during volatility
- Update your order strategy by removing existing orders
- Clear your order book before implementing a new strategy
- React to changing market conditions by canceling pending orders

Order cancellation is a critical risk management function and allows you
to quickly adapt to changing market conditions.

Example use cases:
- Canceling limit orders when your outlook changes
- Removing all orders during unexpected market volatility
- Canceling a specific order identified by order ID
- Clearing all orders for a specific market
- Removing stale orders before placing new ones

Calling without any parameters will cancel all orders.

Succesful response indicates that orders were queued for cancellation.
Check order status using order id.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
order_idNoOrder id (received from create_order)
client_idNoClient id (provided by you on create_order)
market_idNoMarket is the market to cancel orders forALL

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
idYesUnique order identifier generated by Paradex
stpYesSelf Trade Prevention mode
sideYesOrder side
sizeYesOrder size
typeYesOrder type
flagsYesOrder flags, allow flag: REDUCE_ONLY
priceYesOrder price. 0 for MARKET orders
marketYesMarket
seq_noYesUnique increasing number that is assigned to this order update and changes on every order update
statusYesOrder status
accountYesParadex Account
client_idYesClient order id provided by the client at order creation
timestampYesOrder signature timestamp
created_atYesOrder creation time
instructionYesExecution instruction for order matching
received_atYesTimestamp in milliseconds when order was received by API service
published_atYesTimestamp in milliseconds when order was sent to the client
cancel_reasonYesReason for order cancellation if it was closed by cancel
trigger_priceYesTrigger price for stop order
avg_fill_priceYesAverage fill price of the order
remaining_sizeYesRemaining size of the order
last_updated_atYesOrder last update time. No changes once status=CLOSED

Implementation Reference

  • The handler function decorated with @server.tool(name="paradex_cancel_orders"). This implements the core logic: authenticates a Paradex client and calls cancel_order, cancel_order_by_client_id, or cancel_all_orders based on provided parameters, returning the OrderState.
    @server.tool(name="paradex_cancel_orders")
    async def cancel_orders(
        order_id: Annotated[
            str, Field(default="", description="Order id (received from create_order)")
        ],
        client_id: Annotated[
            str, Field(default="", description="Client id (provided by you on create_order)")
        ],
        market_id: Annotated[
            str, Field(default="ALL", description="Market is the market to cancel orders for")
        ],
        ctx: Context = None,
    ) -> OrderState:
        """
        Cancel pending orders to manage exposure or adjust your trading strategy.
    
        Use this tool when you need to:
        - Remove stale limit orders that are no longer desirable
        - Quickly reduce market exposure during volatility
        - Update your order strategy by removing existing orders
        - Clear your order book before implementing a new strategy
        - React to changing market conditions by canceling pending orders
    
        Order cancellation is a critical risk management function and allows you
        to quickly adapt to changing market conditions.
    
        Example use cases:
        - Canceling limit orders when your outlook changes
        - Removing all orders during unexpected market volatility
        - Canceling a specific order identified by order ID
        - Clearing all orders for a specific market
        - Removing stale orders before placing new ones
    
        Calling without any parameters will cancel all orders.
    
        Succesful response indicates that orders were queued for cancellation.
        Check order status using order id.
        """
        client = await get_authenticated_paradex_client()
        if order_id:
            response = client.cancel_order(order_id)
        elif client_id:
            response = client.cancel_order_by_client_id(client_id)
        elif market_id:
            response = client.cancel_all_orders(market_id)
        else:
            raise Exception("Either order_id or client_id must be provided.")
        order = OrderState(**response)
        return order
  • Pydantic Field annotations defining the input schema for the paradex_cancel_orders tool, including order_id, client_id, and market_id parameters.
        order_id: Annotated[
            str, Field(default="", description="Order id (received from create_order)")
        ],
        client_id: Annotated[
            str, Field(default="", description="Client id (provided by you on create_order)")
        ],
        market_id: Annotated[
            str, Field(default="ALL", description="Market is the market to cancel orders for")
        ],
        ctx: Context = None,
    ) -> OrderState:
  • The @server.tool decorator registers the cancel_orders function as the MCP tool named 'paradex_cancel_orders'.
    @server.tool(name="paradex_cancel_orders")
  • Uses the helper get_authenticated_paradex_client() to obtain the Paradex client for cancellation operations.
    client = await get_authenticated_paradex_client()

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv1.0.0
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "description": "Order state model representing the current state of an order on Paradex.",
      +  "properties": {
      +    "account": {
      +      "description": "Paradex Account",
      +      "title": "Account",
      +      "type": "string"
      +    },
      +    "avg_fill_price": {
      +      "description": "Average fill price of the order",
      +      "title": "Avg Fill Price",
      +      "type": "string"
      +    },
      +    "cancel_reason": {
      +      "description": "Reason for order cancellation if it was closed by cancel",
      +      "title": "Cancel Reason",
      +      "type": "string"
      +    },
      +    "client_id": {
      +      "description": "Client order id provided by the client at order creation",
      +      "title": "Client Id",
      +      "type": "string"
      +    },
      +    "created_at": {
      +      "description": "Order creation time",
      +      "title": "Created At",
      +      "type": "integer"
      +    },
      +    "flags": {
      +      "description": "Order flags, allow flag: REDUCE_ONLY",
      +      "items": {
      +        "type": "string"
      +      },
      +      "title": "Flags",
      +      "type": "array"
      +    },
      +    "id": {
      +      "description": "Unique order identifier generated by Paradex",
      +      "title": "Id",
      +      "type": "string"
      +    },
      +    "instruction": {
      +      "description": "Execution instruction for order matching",
      +      "title": "Instruction",
      +      "type": "string"
      +    },
      +    "last_updated_at": {
      +      "description": "Order last update time. No changes once status=CLOSED",
      +      "title": "Last Updated At",
      +      "type": "integer"
      +    },
      +    "market": {
      +      "description": "Market",
      +      "title": "Market",
      +      "type": "string"
      +    },
      +    "price": {
      +      "description": "Order price. 0 for MARKET orders",
      +      "title": "Price",
      +      "type": "number"
      +    },
      +    "published_at": {
      +      "description": "Timestamp in milliseconds when order was sent to the client",
      +      "title": "Published At",
      +      "type": "integer"
      +    },
      +    "received_at": {
      +      "description": "Timestamp in milliseconds when order was received by API service",
      +      "title": "Received At",
      +      "type": "integer"
      +    },
      +    "remaining_size": {
      +      "description": "Remaining size of the order",
      +      "title": "Remaining Size",
      +      "type": "number"
      +    },
      +    "seq_no": {
      +      "description": "Unique increasing number that is assigned to this order update and changes on every order update",
      +      "title": "Seq No",
      +      "type": "integer"
      +    },
      +    "side": {
      +      "description": "Order side",
      +      "title": "Side",
      +      "type": "string"
      +    },
      +    "size": {
      +      "description": "Order size",
      +      "title": "Size",
      +      "type": "number"
      +    },
      +    "status": {
      +      "description": "Order status",
      +      "title": "Status",
      +      "type": "string"
      +    },
      +    "stp": {
      +      "description": "Self Trade Prevention mode",
      +      "title": "Stp",
      +      "type": "string"
      +    },
      +    "timestamp": {
      +      "description": "Order signature timestamp",
      +      "title": "Timestamp",
      +      "type": "integer"
      +    },
      +    "trigger_price": {
      +      "description": "Trigger price for stop order",
      +      "title": "Trigger Price",
      +      "type": "string"
      +    },
      +    "type": {
      +      "description": "Order type",
      +      "title": "Type",
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "id",
      +    "account",
      +    "market",
      +    "side",
      +    "type",
      +    "size",
      +    "remaining_size",
      +    "price",
      +    "status",
      +    "created_at",
      +    "last_updated_at",
      +    "timestamp",
      +    "cancel_reason",
      +    "client_id",
      +    "seq_no",
      +    "instruction",
      +    "avg_fill_price",
      +    "stp",
      +    "received_at",
      +    "published_at",
      +    "flags",
      +    "trigger_price"
      +  ],
      +  "title": "OrderState",
      +  "type": "object"
      +}
  2. First observed

TDQS

A4/5.0
Behavior4/5

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

With no annotations provided, the description carries the full burden. It effectively discloses key behavioral traits: it's a mutation tool (canceling orders), includes risk management context, explains the default behavior (cancel all orders if no parameters), and notes that successful response means orders are 'queued for cancellation' with a follow-up step to check status. However, it lacks details on permissions, rate limits, or error handling.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with the core purpose but includes repetitive sections (e.g., 'Example use cases' largely rephrases earlier bullet points). It could be more streamlined, though all content is relevant to understanding the tool's use.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (mutation with risk implications) and no annotations, the description does a good job covering purpose, usage, and behavior. With an output schema present, it doesn't need to explain return values, and it includes practical examples. Minor gaps exist in error handling or advanced constraints.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters (order_id, client_id, market_id). The description adds minimal value beyond the schema, only implying parameter usage through examples (e.g., 'Canceling a specific order identified by order ID') and stating the default behavior. This meets the baseline for high schema coverage.

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 tool's purpose: 'Cancel pending orders to manage exposure or adjust your trading strategy.' It specifies the verb ('cancel') and resource ('pending orders'), and while it doesn't explicitly differentiate from siblings like 'paradex_create_order', the purpose is unambiguous in context.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool, listing five specific scenarios (e.g., 'Remove stale limit orders', 'Quickly reduce market exposure during volatility'). It also clarifies that calling without parameters cancels all orders, offering clear usage rules.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.