@airwallex/developer-mcp
Version:
MCP server for AI agents that assist developers integrating with the Airwallex platform
64 lines (63 loc) • 2.83 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.retrieveDocsToolConfig = exports.retrieveDocsSchema = void 0;
exports.executeRetrieveDocs = executeRetrieveDocs;
const zod_1 = require("zod");
const config_1 = require("../constants/config");
const descriptions_1 = require("../constants/descriptions");
exports.retrieveDocsSchema = zod_1.z.object({
question: zod_1.z
.string()
.min(1)
.describe("The question to search the documentation with."),
source: zod_1.z
.enum([
"product-docs",
"api-docs",
"js-sdk-docs",
"ios-sdk-docs",
"android-sdk-docs",
])
.optional()
.describe("Documentation source to search. OMIT this parameter to search all sources. PREFER to start with a broad search and then narrow down the search with a specific source if needed. Set the source to `product-docs` for information related to integration or migration guides, general product enquiries & detailed API response error code descriptions and reasons. Set the source to `api-docs` for information related to specific API endpoints and for general API-related information related to versioning, authentication, rate limits, etc. Set the source to `js-sdk-docs` for specific information related to Airwallex.js or the Components SDK. For the legacy JS libraries, use `product-docs`, `ios-sdk-docs` for specific information related to the Payments iOS SDK, `android-sdk-docs` for specific information related to the Payments Android SDK."),
});
async function executeRetrieveDocs(args, version) {
const baseUrl = config_1.BASE_URLS.docsSearch;
const response = await fetch(`${baseUrl}/retrieve`, {
body: JSON.stringify({
query: args.question,
sources: args.source ? [args.source] : undefined,
}),
headers: {
"Content-Type": "application/json",
"User-Agent": `awx-local-mcp-server/${version}`,
},
method: "POST",
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = (await response.json());
const results = data.results.map((entry) => ({
content: entry.content,
source_url: entry.source_url,
}));
return {
content: [
{
text: JSON.stringify(results.map((result) => result.content), null, 2),
type: "text",
},
],
};
}
exports.retrieveDocsToolConfig = {
annotations: {
openWorldHint: true,
readOnlyHint: true,
title: "Search Airwallex Product, API & SDK documentation",
},
description: descriptions_1.TOOL_DESCRIPTIONS.RETRIEVE_DOCS,
inputSchema: exports.retrieveDocsSchema,
name: "search_public_docs",
};