/**
* @author Nich
* @website x.com/nichxbt
* @github github.com/nirholas
* @license MIT
*/
// src/tools/binance-sub-account/transfer-api/transferToSubAccount.ts
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { spotClient } from "../../../config/binanceClient.js";
import { z } from "zod";
export function registerBinanceSubAccountTransferToSub(server: McpServer) {
server.tool(
"BinanceSubAccountTransferToSub",
"Transfer assets from one sub-account to another sub-account. Both accounts must belong to the same master account.",
{
toEmail: z.string().email()
.describe("Recipient sub-account email"),
asset: z.string()
.describe("Asset to transfer (e.g., 'BTC', 'USDT')"),
amount: z.number().positive()
.describe("Amount to transfer"),
recvWindow: z.number().int().optional()
.describe("Time window for request validity in ms")
},
async (params) => {
try {
const response = await spotClient.restAPI.subAccountTransferSubToSub({
toEmail: params.toEmail,
asset: params.asset,
amount: params.amount,
...(params.recvWindow && { recvWindow: params.recvWindow })
});
const data = await response.data();
return {
content: [{
type: "text",
text: `✅ Transfer successful!\n\nTo: ${params.toEmail}\nAsset: ${params.asset}\nAmount: ${params.amount}\n\nTransaction: ${JSON.stringify(data, null, 2)}`
}]
};
} catch (error) {
const errorMessage = error instanceof Error ? error.message : String(error);
return {
content: [{ type: "text", text: `❌ Failed to transfer: ${errorMessage}` }],
isError: true
};
}
}
);
}