/**
* @author Nich
* @website x.com/nichxbt
* @github github.com/nirholas
* @license MIT
*/
// src/tools/binance-margin/cross-margin-api/crossMarginCancelAllOrders.ts
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { marginClient } from "../../../config/binanceClient.js";
import { z } from "zod";
export function registerBinanceCrossMarginCancelAllOrders(server: McpServer) {
server.tool(
"BinanceCrossMarginCancelAllOrders",
"Cancel all open orders on a symbol in Cross Margin account.",
{
symbol: z.string().describe("Symbol of the trading pair (e.g., BTCUSDT)"),
isIsolated: z.enum(["TRUE", "FALSE"]).optional().describe("For isolated margin, default FALSE"),
recvWindow: z.number().int().optional().describe("Time window for request validity")
},
async (params) => {
try {
const response = await marginClient.restAPI.marginAccountCancelAllOpenOrdersOnASymbol({
symbol: params.symbol,
...(params.isIsolated && { isIsolated: params.isIsolated }),
...(params.recvWindow && { recvWindow: params.recvWindow })
});
const data = await response.data();
return {
content: [{
type: "text",
text: `All orders cancelled for ${params.symbol}: ${JSON.stringify(data, null, 2)}`
}]
};
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
return {
content: [{ type: "text", text: `Failed to cancel all orders: ${errorMessage}` }],
isError: true
};
}
}
);
}