@nbakka/mcp-appium 2.0.22 → 2.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/server.js +17 -29
- package/package.json +1 -1
package/lib/server.js
CHANGED
|
@@ -17,9 +17,6 @@ const getAgentVersion = () => {
|
|
|
17
17
|
const json = require("../package.json");
|
|
18
18
|
return json.version;
|
|
19
19
|
};
|
|
20
|
-
const selectedSheetContext = {
|
|
21
|
-
sheetName: null,
|
|
22
|
-
};
|
|
23
20
|
|
|
24
21
|
const createMcpServer = () => {
|
|
25
22
|
const server = new mcp_js_1.McpServer({
|
|
@@ -278,29 +275,18 @@ const createMcpServer = () => {
|
|
|
278
275
|
);
|
|
279
276
|
|
|
280
277
|
tool(
|
|
281
|
-
"
|
|
282
|
-
"MUST be
|
|
278
|
+
"fetch_google_sheet_locators",
|
|
279
|
+
"Follow this instructions strictly. MUST be invoked after mobile_learn_current_app_context. Provide the Google Sheet name to fetch locatorName and androidLocator from the specified sheet.",
|
|
283
280
|
{
|
|
284
|
-
sheetName: {
|
|
281
|
+
sheetName: {
|
|
282
|
+
type: "string",
|
|
283
|
+
description: "Exact name of the Google Sheets tab (sheet) to fetch data from.",
|
|
284
|
+
required: true,
|
|
285
|
+
},
|
|
285
286
|
},
|
|
286
287
|
async ({ sheetName }) => {
|
|
287
|
-
if (!sheetName) {
|
|
288
|
-
return "Error: sheetName is required.";
|
|
289
|
-
}
|
|
290
|
-
selectedSheetContext.sheetName = sheetName.trim();
|
|
291
|
-
return `Sheet name "${selectedSheetContext.sheetName}" saved. Now call fetch_google_sheet_locators to fetch data.`;
|
|
292
|
-
}
|
|
293
|
-
);
|
|
294
|
-
|
|
295
|
-
// Tool 2: fetch locator data using previously selected sheet name
|
|
296
|
-
tool(
|
|
297
|
-
"fetch_google_sheet_locators",
|
|
298
|
-
"MUST be called after select_google_sheet. Fetch locatorName and androidLocator from the sheet set by select_google_sheet. Please call select_google_sheet first.",
|
|
299
|
-
{},
|
|
300
|
-
async () => {
|
|
301
|
-
const sheetName = selectedSheetContext.sheetName;
|
|
302
|
-
if (!sheetName) {
|
|
303
|
-
return "Error: Sheet name not set. Please call select_google_sheet first.";
|
|
288
|
+
if (!sheetName || sheetName.trim() === "") {
|
|
289
|
+
return "Error: sheetName is required and cannot be empty.";
|
|
304
290
|
}
|
|
305
291
|
|
|
306
292
|
try {
|
|
@@ -308,8 +294,8 @@ const createMcpServer = () => {
|
|
|
308
294
|
const path = require('path');
|
|
309
295
|
const { google } = require('googleapis');
|
|
310
296
|
|
|
311
|
-
//
|
|
312
|
-
const keyFile = path.join(__dirname, '
|
|
297
|
+
// Adjust path to your config folder as needed
|
|
298
|
+
const keyFile = path.join(__dirname, 'config', 'secret.json');
|
|
313
299
|
const credentials = JSON.parse(await fs.readFile(keyFile, 'utf-8'));
|
|
314
300
|
|
|
315
301
|
const auth = new google.auth.GoogleAuth({
|
|
@@ -329,12 +315,13 @@ const createMcpServer = () => {
|
|
|
329
315
|
return `Sheet "${sheetName}" is empty or does not exist.`;
|
|
330
316
|
}
|
|
331
317
|
|
|
332
|
-
|
|
333
|
-
const
|
|
334
|
-
const
|
|
318
|
+
// Normalize header keys for safe case-insensitive lookup
|
|
319
|
+
const header = rows[0].map(h => h.toString().toLowerCase().trim());
|
|
320
|
+
const locatorNameIdx = header.indexOf('locator name');
|
|
321
|
+
const androidLocatorIdx = header.findIndex(h => h === 'android xpath' || h === 'android locator');
|
|
335
322
|
|
|
336
323
|
if (locatorNameIdx === -1 || androidLocatorIdx === -1) {
|
|
337
|
-
return `Required columns "
|
|
324
|
+
return `Required columns "locator name" and/or "android xpath" not found in sheet "${sheetName}".`;
|
|
338
325
|
}
|
|
339
326
|
|
|
340
327
|
const extracted = rows.slice(1)
|
|
@@ -351,6 +338,7 @@ const createMcpServer = () => {
|
|
|
351
338
|
}
|
|
352
339
|
);
|
|
353
340
|
|
|
341
|
+
|
|
354
342
|
return server;
|
|
355
343
|
};
|
|
356
344
|
|