UNPKG

@airwallex/developer-mcp

Version:

MCP server for AI agents that assist developers integrating with the Airwallex platform

84 lines (83 loc) 2.96 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createTransferToolConfig = exports.createTransferSchema = void 0; exports.executeCreateTransfer = executeCreateTransfer; const uuid_1 = require("uuid"); const zod_1 = require("zod"); const descriptions_1 = require("../constants/descriptions"); exports.createTransferSchema = zod_1.z .object({ beneficiary_id: zod_1.z .string() .min(1) .describe("The ID of the beneficiary to send the transfer to."), reason: zod_1.z.string().min(1), reference: zod_1.z.string().min(1), source_amount: zod_1.z .number() .positive() .optional() .describe("The amount to be transferred from the source wallet."), source_currency: zod_1.z .string() .length(3) .describe("The currency of the source amount."), transfer_amount: zod_1.z .number() .positive() .optional() .describe("The amount that the beneficiary must receive."), transfer_currency: zod_1.z .string() .length(3) .describe("The currency of the transfer amount."), transfer_method: zod_1.z .enum(["LOCAL", "SWIFT"]) .describe("The method of the transfer."), }) .refine((data) => { const hasTransferAmount = data.transfer_amount !== undefined; const hasSourceAmount = data.source_amount !== undefined; return hasTransferAmount !== hasSourceAmount; }, { message: "Exactly one of transfer_amount OR source_amount must be provided, but not both.", }); async function executeCreateTransfer(airwallex, args) { try { const requestBody = { beneficiary_id: args.beneficiary_id, reason: args.reason, reference: args.reference, request_id: (0, uuid_1.v4)(), source_amount: args.source_amount, source_currency: args.source_currency, transfer_amount: args.transfer_amount, transfer_currency: args.transfer_currency, transfer_method: args.transfer_method, }; const response = (await airwallex.post("/api/v1/transfers/create", requestBody)); return { content: [ { text: JSON.stringify(response, null, 2), type: "text", }, ], }; } catch (error) { const statusCode = error?.status || error?.statusCode || 500; const errorMessage = error?.message || "Unknown error occurred"; throw new Error(`Failed to create transfer (${statusCode}): ${errorMessage}`); } } exports.createTransferToolConfig = { annotations: { openWorldHint: true, readOnlyHint: false, title: "Create transfer", }, description: descriptions_1.TOOL_DESCRIPTIONS.CREATE_TRANSFER, inputSchema: exports.createTransferSchema, name: "create_transfer", };