@nbakka/mcp-appium 3.0.20 → 3.0.21
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 +68 -68
- package/package.json +1 -1
package/lib/server.js
CHANGED
|
@@ -147,76 +147,76 @@ const createMcpServer = () => {
|
|
|
147
147
|
const fs = require('fs').promises;
|
|
148
148
|
const path = require('path');
|
|
149
149
|
|
|
150
|
-
tool(
|
|
151
|
-
"mobile_learn_current_app_context",
|
|
152
|
-
"Follow these instructions strictly to navigate through the app. This should be the first step after launching the app and before performing any tests. Google Sheet name to fetch locatorName and androidLocator from the specified sheet. NOTE: Only use the locator data from the Google Sheet at the end while generating test cases, don't use to navigate through screens",
|
|
153
|
-
{
|
|
154
|
-
sheetName: zod_1.z.string().describe("The name of the Google Sheet to fetch locator data from").default("PDP"),
|
|
155
|
-
},
|
|
156
|
-
async ({ sheetName }) => {
|
|
157
|
-
try {
|
|
158
|
-
// Read app context notes from file
|
|
159
|
-
const notesFilePath = path.join(__dirname, 'app_context.txt');
|
|
160
|
-
const fileContent = await fs.readFile(notesFilePath, 'utf-8');
|
|
161
|
-
|
|
162
|
-
const notes = fileContent
|
|
163
|
-
.split('\n')
|
|
164
|
-
.map(line => line.trim())
|
|
165
|
-
.filter(line => line.length > 0);
|
|
166
|
-
|
|
167
|
-
// Initialize response object
|
|
168
|
-
const context = { notes, locatorData: null };
|
|
169
|
-
|
|
170
|
-
if (sheetName && sheetName.trim() !== '') {
|
|
171
|
-
// Load Google Sheets credentials with keyFile option (no manual parse)
|
|
172
|
-
const keyFile = path.join(os.homedir(), 'Desktop', 'secret.json');
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
const auth = new google.auth.GoogleAuth({
|
|
176
|
-
keyFile,
|
|
177
|
-
scopes: ['https://www.googleapis.com/auth/spreadsheets.readonly'],
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
const authClient = await auth.getClient();
|
|
181
|
-
const sheets = google.sheets({ version: 'v4', auth: authClient });
|
|
182
|
-
const spreadsheetId = '1UapR81AxaztDUlPGDV-_EwHo2hWXkKCZXl8ALsvIyxA';
|
|
183
|
-
|
|
184
|
-
const range = `${sheetName}!A1:Z1000`;
|
|
185
|
-
const res = await sheets.spreadsheets.values.get({ spreadsheetId, range });
|
|
186
|
-
const rows = res.data.values;
|
|
187
|
-
|
|
188
|
-
if (!rows || rows.length === 0) {
|
|
189
|
-
return `Sheet "${sheetName}" is empty or does not exist. Notes loaded: ${JSON.stringify(notes)}`;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// Map headers exactly (trimmed, case-sensitive)
|
|
193
|
-
const header = rows[0].map(h => h.toString().trim());
|
|
194
|
-
|
|
195
|
-
const locatorNameIdx = header.indexOf('locatorName');
|
|
196
|
-
const androidLocatorIdx = header.indexOf('androidLocator');
|
|
197
|
-
|
|
198
|
-
if (locatorNameIdx === -1 || androidLocatorIdx === -1) {
|
|
199
|
-
return `Required columns "locatorName" and/or "androidLocator" not found in sheet "${sheetName}". Notes loaded: ${JSON.stringify(notes)}`;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
const locatorData = rows.slice(1)
|
|
203
|
-
.filter(row => row[locatorNameIdx] && row[androidLocatorIdx])
|
|
204
|
-
.map(row => ({
|
|
205
|
-
locatorName: row[locatorNameIdx],
|
|
206
|
-
androidLocator: row[androidLocatorIdx],
|
|
207
|
-
}));
|
|
208
|
-
|
|
209
|
-
context.locatorData = locatorData;
|
|
210
|
-
}
|
|
211
|
-
return `App context learned: ${JSON.stringify(context)}`;
|
|
212
|
-
} catch (error) {
|
|
213
|
-
return `Error reading app context notes or fetching locator data: ${error.message}`;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
);
|
|
150
|
+
// tool(
|
|
151
|
+
// "mobile_learn_current_app_context",
|
|
152
|
+
// "Follow these instructions strictly to navigate through the app. This should be the first step after launching the app and before performing any tests. Google Sheet name to fetch locatorName and androidLocator from the specified sheet. NOTE: Only use the locator data from the Google Sheet at the end while generating test cases, don't use to navigate through screens",
|
|
153
|
+
// {
|
|
154
|
+
// sheetName: zod_1.z.string().describe("The name of the Google Sheet to fetch locator data from").default("PDP"),
|
|
155
|
+
// },
|
|
156
|
+
// async ({ sheetName }) => {
|
|
157
|
+
// try {
|
|
158
|
+
// // Read app context notes from file
|
|
159
|
+
// const notesFilePath = path.join(__dirname, 'app_context.txt');
|
|
160
|
+
// const fileContent = await fs.readFile(notesFilePath, 'utf-8');
|
|
161
|
+
//
|
|
162
|
+
// const notes = fileContent
|
|
163
|
+
// .split('\n')
|
|
164
|
+
// .map(line => line.trim())
|
|
165
|
+
// .filter(line => line.length > 0);
|
|
166
|
+
//
|
|
167
|
+
// // Initialize response object
|
|
168
|
+
// const context = { notes, locatorData: null };
|
|
169
|
+
//
|
|
170
|
+
// if (sheetName && sheetName.trim() !== '') {
|
|
171
|
+
// // Load Google Sheets credentials with keyFile option (no manual parse)
|
|
172
|
+
// const keyFile = path.join(os.homedir(), 'Desktop', 'secret.json');
|
|
173
|
+
//
|
|
174
|
+
//
|
|
175
|
+
// const auth = new google.auth.GoogleAuth({
|
|
176
|
+
// keyFile,
|
|
177
|
+
// scopes: ['https://www.googleapis.com/auth/spreadsheets.readonly'],
|
|
178
|
+
// });
|
|
179
|
+
//
|
|
180
|
+
// const authClient = await auth.getClient();
|
|
181
|
+
// const sheets = google.sheets({ version: 'v4', auth: authClient });
|
|
182
|
+
// const spreadsheetId = '1UapR81AxaztDUlPGDV-_EwHo2hWXkKCZXl8ALsvIyxA';
|
|
183
|
+
//
|
|
184
|
+
// const range = `${sheetName}!A1:Z1000`;
|
|
185
|
+
// const res = await sheets.spreadsheets.values.get({ spreadsheetId, range });
|
|
186
|
+
// const rows = res.data.values;
|
|
187
|
+
//
|
|
188
|
+
// if (!rows || rows.length === 0) {
|
|
189
|
+
// return `Sheet "${sheetName}" is empty or does not exist. Notes loaded: ${JSON.stringify(notes)}`;
|
|
190
|
+
// }
|
|
191
|
+
//
|
|
192
|
+
// // Map headers exactly (trimmed, case-sensitive)
|
|
193
|
+
// const header = rows[0].map(h => h.toString().trim());
|
|
194
|
+
//
|
|
195
|
+
// const locatorNameIdx = header.indexOf('locatorName');
|
|
196
|
+
// const androidLocatorIdx = header.indexOf('androidLocator');
|
|
197
|
+
//
|
|
198
|
+
// if (locatorNameIdx === -1 || androidLocatorIdx === -1) {
|
|
199
|
+
// return `Required columns "locatorName" and/or "androidLocator" not found in sheet "${sheetName}". Notes loaded: ${JSON.stringify(notes)}`;
|
|
200
|
+
// }
|
|
201
|
+
//
|
|
202
|
+
// const locatorData = rows.slice(1)
|
|
203
|
+
// .filter(row => row[locatorNameIdx] && row[androidLocatorIdx])
|
|
204
|
+
// .map(row => ({
|
|
205
|
+
// locatorName: row[locatorNameIdx],
|
|
206
|
+
// androidLocator: row[androidLocatorIdx],
|
|
207
|
+
// }));
|
|
208
|
+
//
|
|
209
|
+
// context.locatorData = locatorData;
|
|
210
|
+
// }
|
|
211
|
+
// return `App context learned: ${JSON.stringify(context)}`;
|
|
212
|
+
// } catch (error) {
|
|
213
|
+
// return `Error reading app context notes or fetching locator data: ${error.message}`;
|
|
214
|
+
// }
|
|
215
|
+
// }
|
|
216
|
+
// );
|
|
217
217
|
|
|
218
218
|
tool(
|
|
219
|
-
"
|
|
219
|
+
"mobile_learn_testcases_generation_context",
|
|
220
220
|
"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.",
|
|
221
221
|
{},
|
|
222
222
|
async () => {
|