trade_execute
Execute market or limit orders for perpetual futures trading on supported exchanges after user confirmation.
Instructions
Execute a trade. IMPORTANT: Always call trade_preview first and get explicit user confirmation before calling this tool. Supports market and limit orders.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| exchange | Yes | Exchange: pacifica, hyperliquid, or lighter | |
| symbol | Yes | Trading symbol (e.g., BTC, ETH, SOL) | |
| side | Yes | Order side | |
| size | Yes | Order size (base currency units) | |
| orderType | No | Order type | market |
| price | No | Limit price (required for limit orders) | |
| reduceOnly | No | Reduce-only order (close position only) |
Implementation Reference
- src/mcp-server.ts:1454-1496 (handler)The trade_execute tool implementation in the MCP server, which interacts with exchange adapters to place market or limit orders.
"trade_execute", "Execute a trade. IMPORTANT: Always call trade_preview first and get explicit user confirmation before calling this tool. Supports market and limit orders.", { exchange: z.string().describe("Exchange: pacifica, hyperliquid, or lighter"), symbol: z.string().describe("Trading symbol (e.g., BTC, ETH, SOL)"), side: z.enum(["buy", "sell"]).describe("Order side"), size: z.string().describe("Order size (base currency units)"), orderType: z.enum(["market", "limit"]).default("market").describe("Order type"), price: z.string().optional().describe("Limit price (required for limit orders)"), reduceOnly: z.boolean().default(false).describe("Reduce-only order (close position only)"), }, async ({ exchange, symbol, side, size, orderType, price, reduceOnly }) => { try { const adapter = await getOrCreateAdapter(exchange); let result: unknown; if (orderType === "limit") { if (!price) throw new Error("Price is required for limit orders"); result = await adapter.limitOrder(symbol, side, price, size, { reduceOnly }); } else { result = await adapter.marketOrder(symbol, side, size); } // Fetch updated position const positions = await adapter.getPositions(); const pos = positions.find(p => p.symbol.toUpperCase().includes(symbol.toUpperCase())); return { content: [{ type: "text", text: ok({ executed: true, order: { exchange, symbol, side, size, orderType, price }, result, currentPosition: pos ?? null, }, { exchange, type: "execution" }), }], }; } catch (e) { return { content: [{ type: "text", text: err(e instanceof Error ? e.message : String(e)) }], isError: true }; } }, );