-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-mcp-loading.js
More file actions
41 lines (32 loc) · 1.14 KB
/
test-mcp-loading.js
File metadata and controls
41 lines (32 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import fs from "fs";
import path from "path";
import { fileURLToPath } from 'url';
import xml2js from "xml2js";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const XML_PATH = path.join(__dirname, "server/src/main/resources/request-handlers.xml");
async function testLoad() {
console.log(`Testing XML loading from: ${XML_PATH}`);
if (!fs.existsSync(XML_PATH)) {
console.error("ERROR: File does not exist!");
return;
}
try {
const xml = fs.readFileSync(XML_PATH, "utf-8");
const parser = new xml2js.Parser();
const result = await parser.parseStringPromise(xml);
if (!result.Data || !result.Data.RequestHandler) {
console.error("ERROR: Invalid XML structure");
return;
}
const tools = result.Data.RequestHandler.map((handler) => {
const nameFull = handler.$.Name;
return nameFull.split(".").pop().replace("RequestHandler", "");
});
console.log(`SUCCESS: Found ${tools.length} tools.`);
console.log("First 5 tools:", tools.slice(0, 5));
} catch (error) {
console.error("ERROR parsing XML:", error);
}
}
testLoad();