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: [] } };

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