UNPKG

@airwallex/developer-mcp

Version:

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

64 lines (63 loc) 2.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getFxQuoteToolConfig = exports.getFxQuoteSchema = void 0; exports.executeGetFxQuote = executeGetFxQuote; const zod_1 = require("zod"); const descriptions_1 = require("../constants/descriptions"); exports.getFxQuoteSchema = zod_1.z .object({ buy_amount: zod_1.z .number() .positive() .describe("The amount to buy. Skip this if you are setting sell_amount") .optional(), buy_currency: zod_1.z.string().length(3).describe("The currency to buy"), sell_amount: zod_1.z .number() .positive() .describe("The amount to sell. Skip this if you are setting buy_amount") .optional(), sell_currency: zod_1.z.string().length(3).describe("The currency to sell"), validity: zod_1.z .enum(["MIN_1", "MIN_15", "MIN_30", "HR_1", "HR_4", "HR_8", "HR_24"]) .describe("The validity of the quote"), }) .refine((data) => (data.buy_amount !== undefined && data.sell_amount === undefined) || (data.buy_amount === undefined && data.sell_amount !== undefined), { message: "Exactly one of buy_amount or sell_amount must be set", path: ["buy_amount", "sell_amount"], }); async function executeGetFxQuote(airwallex, args) { try { const response = (await airwallex.post("/api/v1/fx/quotes/create", { buy_amount: args.buy_amount, buy_currency: args.buy_currency, sell_amount: args.sell_amount, sell_currency: args.sell_currency, validity: args.validity, })); 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 get FX quote (${statusCode}): ${errorMessage}`); } } exports.getFxQuoteToolConfig = { annotations: { openWorldHint: true, readOnlyHint: true, title: "Get FX quote", }, description: descriptions_1.TOOL_DESCRIPTIONS.GET_FX_QUOTE, inputSchema: exports.getFxQuoteSchema, name: "get_fx_quote", };