@nbakka/mcp-appium 3.0.23 → 3.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.
Files changed (2) hide show
  1. package/lib/server.js +131 -25
  2. package/package.json +1 -1
package/lib/server.js CHANGED
@@ -336,32 +336,138 @@ tool(
336
336
  }
337
337
  );
338
338
 
339
- tool(
340
- "mobile_learn_testcases_generation_context",
341
- "Reads previously saved app context notes and returns them so they can be used to validate or update test cases. This should be executed before generating manual test cases.",
342
- {},
343
- async () => {
344
- try {
345
- // Read app context notes from file
346
- const notesFilePath = path.join(__dirname, "app_context.txt");
347
- const fileContent = await fs.readFile(notesFilePath, "utf-8");
348
-
349
- const notes = fileContent
350
- .split("\n")
351
- .map(line => line.trim())
352
- .filter(line => line.length > 0);
353
-
354
- if (notes.length === 0) {
355
- return "No app context notes found.";
356
- }
357
-
358
- return `App context loaded for testcase generation: ${JSON.stringify({ notes })}`;
359
- } catch (error) {
360
- return `Error reading app context notes: ${error.message}`;
361
- }
362
- }
363
- );
339
+ tool(
340
+ "mobile_learn_teststeps_generation_guidelines",
341
+ "Reads previously saved test steps generation guidelines and returns them so they can be used to validate or update test steps. This should be executed before generating manual test steps.",
342
+ {},
343
+ async () => {
344
+ try {
345
+ // Read test steps generation guidelines from Desktop
346
+ const guidelinesFilePath = path.join(os.homedir(), 'Desktop', 'teststeps_generation_guidelines.txt');
347
+ const fileContent = await fs.readFile(guidelinesFilePath, "utf-8");
348
+
349
+ const guidelines = fileContent
350
+ .split("\n")
351
+ .map(line => line.trim())
352
+ .filter(line => line.length > 0);
353
+
354
+ if (guidelines.length === 0) {
355
+ return "No test steps generation guidelines found.";
356
+ }
357
+
358
+ return `Test steps generation guidelines loaded: ${JSON.stringify({ guidelines })}`;
359
+ } catch (error) {
360
+ return `Error reading test steps generation guidelines: ${error.message}`;
361
+ }
362
+ }
363
+ );
364
+
365
+ // Tool 3: Update Test Scenario (Always appends with green color)
366
+ tool(
367
+ "mobile_update_test_scenario",
368
+ "Updates the Test Scenario (Testcases column) in Google Sheet for outdated scenarios. Always keeps the existing scenario and adds the updated scenario in green color on a new line.",
369
+ {
370
+ sheetName: zod_1.z.string().describe("The name of the Google Sheet tab"),
371
+ rowNumber: zod_1.z.number().describe("The row number to update"),
372
+ columnLetter: zod_1.z.string().describe("The column letter for Testcases column"),
373
+ updatedScenario: zod_1.z.string().describe("The updated test scenario content"),
374
+ },
375
+ async ({ sheetName, rowNumber, columnLetter, updatedScenario }) => {
376
+ try {
377
+ // Load Google Sheets credentials with write permissions
378
+ const keyFile = path.join(os.homedir(), 'Desktop', 'secret.json');
379
+
380
+ const auth = new google.auth.GoogleAuth({
381
+ keyFile,
382
+ scopes: ['https://www.googleapis.com/auth/spreadsheets'],
383
+ });
384
+
385
+ const authClient = await auth.getClient();
386
+ const sheets = google.sheets({ version: 'v4', auth: authClient });
387
+ const spreadsheetId = '1jAilVUeQW99JUYj1KL4jovoxeWGUnsIcY_nMJR5H6dc';
388
+
389
+ const cellReference = `${sheetName}!${columnLetter}${rowNumber}`;
390
+
391
+ // First, read the existing scenario
392
+ const getRes = await sheets.spreadsheets.values.get({
393
+ spreadsheetId,
394
+ range: cellReference
395
+ });
396
+
397
+ const existingScenario = getRes.data.values && getRes.data.values[0] && getRes.data.values[0][0]
398
+ ? getRes.data.values[0][0]
399
+ : '';
400
+
401
+ if (!existingScenario) {
402
+ return `No existing scenario found at ${cellReference}. Cannot append to empty cell.`;
403
+ }
404
+
405
+ // Combine: existing scenario + newline + updated scenario
406
+ const combinedContent = `${existingScenario}\n${updatedScenario}`;
364
407
 
408
+ // Get sheet ID dynamically
409
+ const sheetsMetadata = await sheets.spreadsheets.get({ spreadsheetId });
410
+ const sheetId = sheetsMetadata.data.sheets.find(s => s.properties.title === sheetName)?.properties.sheetId || 0;
411
+
412
+ // Calculate text positions
413
+ const existingLength = existingScenario.length;
414
+ const newTextStartIndex = existingLength + 1; // +1 for newline
415
+
416
+ // Apply green color formatting to the new text
417
+ const batchUpdateRes = await sheets.spreadsheets.batchUpdate({
418
+ spreadsheetId,
419
+ resource: {
420
+ requests: [
421
+ {
422
+ repeatCell: {
423
+ range: {
424
+ sheetId: sheetId,
425
+ startRowIndex: rowNumber - 1,
426
+ endRowIndex: rowNumber,
427
+ startColumnIndex: columnLetter.charCodeAt(0) - 65,
428
+ endColumnIndex: columnLetter.charCodeAt(0) - 64
429
+ },
430
+ cell: {
431
+ userEnteredValue: {
432
+ stringValue: combinedContent
433
+ },
434
+ textFormatRuns: [
435
+ // Keep existing text in default color
436
+ {
437
+ startIndex: 0,
438
+ format: {}
439
+ },
440
+ // New text in green
441
+ {
442
+ startIndex: newTextStartIndex,
443
+ format: {
444
+ foregroundColor: {
445
+ red: 0.0,
446
+ green: 0.5,
447
+ blue: 0.0
448
+ }
449
+ }
450
+ }
451
+ ]
452
+ },
453
+ fields: 'userEnteredValue,textFormatRuns'
454
+ }
455
+ }
456
+ ]
457
+ }
458
+ });
459
+
460
+ if (batchUpdateRes.status === 200) {
461
+ return `Successfully appended updated scenario at ${cellReference}. New scenario added in green color: "${updatedScenario.substring(0, 100)}${updatedScenario.length > 100 ? '...' : ''}"`;
462
+ } else {
463
+ return `Failed to append scenario. Status: ${batchUpdateRes.status}`;
464
+ }
465
+
466
+ } catch (error) {
467
+ return `Error updating test scenario: ${error.message}`;
468
+ }
469
+ }
470
+ );
365
471
 
366
472
  tool("mobile_list_elements_on_screennn", "List elements on screen and their coordinates, with display text or accessibility label. Returns the complete XML structure to maintain hierarchy for XPath creation. Do not cache this result.", {}, async ({}) => {
367
473
  requireRobot();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nbakka/mcp-appium",
3
- "version": "3.0.23",
3
+ "version": "3.0.24",
4
4
  "description": "Appium MCP",
5
5
  "engines": {
6
6
  "node": ">=18"