@nbakka/mcp-appium 2.0.5 → 2.0.7
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 +14 -24
- package/package.json +1 -1
package/lib/server.js
CHANGED
|
@@ -146,7 +146,6 @@ const createMcpServer = () => {
|
|
|
146
146
|
tool("mobile_list_elements_on_screen", "List elements on screen and their coordinates, with display text or accessibility label. Do not cache this result.", {}, async ({}) => {
|
|
147
147
|
requireRobot();
|
|
148
148
|
const elements = await robot.getElementsOnScreen();
|
|
149
|
-
console.log(elements)
|
|
150
149
|
const result = elements.map(element => {
|
|
151
150
|
const out = {
|
|
152
151
|
type: element.type,
|
|
@@ -214,43 +213,34 @@ await new Promise(resolve => setTimeout(resolve, 5000));
|
|
|
214
213
|
const orientation = await robot.getOrientation();
|
|
215
214
|
return `Current device orientation is ${orientation}`;
|
|
216
215
|
});
|
|
216
|
+
|
|
217
217
|
tool(
|
|
218
|
-
"
|
|
219
|
-
"
|
|
218
|
+
"mobile_get_active_session",
|
|
219
|
+
"retrieve an active mobile session ID for reuse across tools",
|
|
220
220
|
{},
|
|
221
221
|
async () => {
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
"appium:udid": "emulator-5554",
|
|
225
|
-
"appium:automationName": "UiAutomator2",
|
|
226
|
-
"appium:noReset": true,
|
|
227
|
-
"appium:appPackage": "com.locon.housing",
|
|
228
|
-
"appium:appActivity": "com.locon.housing.presentation.MainActivity",
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
const payload = {
|
|
232
|
-
capabilities: {
|
|
233
|
-
firstMatch: [{}],
|
|
234
|
-
alwaysMatch: capabilities,
|
|
235
|
-
},
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
const response = await fetch("http://localhost:4723/session", {
|
|
239
|
-
method: "POST",
|
|
222
|
+
const response = await fetch("http://localhost:4723/sessions", {
|
|
223
|
+
method: "GET",
|
|
240
224
|
headers: { "Content-Type": "application/json" },
|
|
241
|
-
body: JSON.stringify(payload),
|
|
242
225
|
});
|
|
243
226
|
|
|
244
227
|
if (!response.ok) {
|
|
245
|
-
throw new Error(`Failed to
|
|
228
|
+
throw new Error(`Failed to get sessions: ${response.statusText}`);
|
|
246
229
|
}
|
|
247
230
|
|
|
248
231
|
const json = await response.json();
|
|
249
|
-
|
|
232
|
+
|
|
233
|
+
if (!json.value || json.value.length === 0) {
|
|
234
|
+
throw new Error("No active sessions found");
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Return the first active sessionId
|
|
238
|
+
return `Active sessionId: ${json.value[0].id}`;
|
|
250
239
|
}
|
|
251
240
|
);
|
|
252
241
|
|
|
253
242
|
|
|
243
|
+
|
|
254
244
|
tool(
|
|
255
245
|
"mobile_click",
|
|
256
246
|
"Click an element identified by text using path",
|