Skip to main content
Glama
t3rmed

Hyperliquid MCP Server

by t3rmed

cancel_all_orders

Cancel all open trading orders on Hyperliquid DEX to manage positions and clear pending transactions.

Instructions

Cancel all open orders

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Python handler function for the 'cancel_all_orders' tool. It calls the HyperliquidClient's cancel_all_orders method and returns a formatted success or error response.
    async def handle_cancel_all_orders(client: HyperliquidClient, args: Dict[str, Any]) -> Dict[str, Any]:
        """Handle cancel all orders request."""
        result = await client.cancel_all_orders()
    
        if not result.success:
            raise ValueError(f"Failed to cancel all orders: {result.error}")
    
        return {
            "content": [
                TextContent(
                    type="text",
                    text=f"All orders cancelled successfully!\n\n{json.dumps(result.data, indent=2)}",
                )
            ]
        }
  • Python tool registration for 'cancel_all_orders' including schema (empty input) and description.
    cancel_all_orders_tool = Tool(
        name="cancel_all_orders",
        description="Cancel all open orders",
        inputSchema={
            "type": "object",
            "properties": {},
            "required": [],
        },
    )
  • Core helper method in HyperliquidClient that performs the API call to cancel all orders using 'cancelByCloid' with empty cancels list.
    async def cancel_all_orders(self) -> ApiResponse[Any]:
        """Cancel all orders."""
        try:
            if not self.account:
                raise ValueError("Private key required for trading operations")
    
            action = {"type": "cancelByCloid", "cancels": []}
            nonce = self._generate_nonce()
            signature = await self._sign_action(action, nonce)
    
            payload = {
                "action": action,
                "nonce": nonce,
                "signature": signature,
                "vaultAddress": self.config.wallet_address,
            }
    
            response = await self.client.post("/exchange", json=payload)
            response.raise_for_status()
            return ApiResponse(success=True, data=response.json())
        except Exception as e:
            return ApiResponse(success=False, error=str(e))
  • TypeScript handler function for the 'cancel_all_orders' tool. Mirrors the Python version, calling client.cancelAllOrders() and formatting response.
    export async function handleCancelAllOrders(client: HyperliquidClient, args: any) {
      const result = await client.cancelAllOrders();
    
      if (!result.success) {
        throw new Error(`Failed to cancel all orders: ${result.error}`);
      }
    
      return {
        content: [
          {
            type: 'text',
            text: `All orders cancelled successfully!\n\n${JSON.stringify(result.data, null, 2)}`
          }
        ]
      };
    }
  • TypeScript tool registration for 'cancel_all_orders' including empty input schema.
    export const cancelAllOrdersTool: Tool = {
      name: 'cancel_all_orders',
      description: 'Cancel all open orders',
      inputSchema: {
        type: 'object',
        properties: {},
        required: []
      }
    };
Behavior2/5

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

No annotations are provided, so the description carries the full burden. 'Cancel all open orders' implies a destructive write operation, but it doesn't disclose critical behavioral traits like whether this action is irreversible, requires confirmation, affects only certain order types, has rate limits, or returns any confirmation data. The description is minimal and lacks necessary context for safe use.

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

Conciseness5/5

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

The description is a single, efficient sentence with zero waste—'Cancel all open orders' directly conveys the core action without extra words. It's appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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

Completeness2/5

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

Given the complexity of a destructive trading operation with no annotations and no output schema, the description is incomplete. It doesn't explain what 'open orders' entails, the return format (e.g., success confirmation or list of canceled orders), error conditions, or side effects. For a high-stakes tool like this, more context is needed to ensure safe and correct usage.

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

Parameters4/5

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

The tool has 0 parameters with 100% schema description coverage, so the schema fully documents the lack of inputs. The description doesn't need to add parameter details, but it implicitly confirms no parameters are needed by stating 'all open orders' without qualification. This aligns perfectly with the schema, warranting a baseline score of 4 for zero-parameter tools.

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 'Cancel all open orders' clearly states the verb (cancel) and resource (all open orders). It distinguishes from the sibling 'cancel_order' by specifying 'all' versus a single order. However, it doesn't explicitly mention the trading context or differentiate from other cancellation-related tools that might exist, keeping it at a 4 rather than a 5.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'cancel_order' for specific orders or other trading operations. It doesn't mention prerequisites, risks, or appropriate contexts for bulk cancellation versus selective cancellation.

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

Install Server

Other Tools

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/t3rmed/hyperliquid-mcp'

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