@nbakka/mcp-appium 2.0.2 → 2.0.4
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 +26 -31
- package/package.json +1 -1
package/lib/server.js
CHANGED
|
@@ -142,38 +142,33 @@ const createMcpServer = () => {
|
|
|
142
142
|
const screenSize = await robot.getScreenSize();
|
|
143
143
|
return `Screen size is ${screenSize.width}x${screenSize.height} pixels`;
|
|
144
144
|
});
|
|
145
|
-
tool("mobile_click_on_element_by_text", "Click on the screen element identified by its text", {
|
|
146
|
-
text: zod_1.z.string().describe("The visible text of the element to click"),
|
|
147
|
-
}, async ({ text }) => {
|
|
148
|
-
requireRobot();
|
|
149
|
-
const xpath = `//*[@text="${text}"]`;
|
|
150
|
-
const element = await robot.clickByXPath(xpath);
|
|
151
|
-
if (!element) {
|
|
152
|
-
throw new Error(`Element with text "${text}" not found`);
|
|
153
|
-
}
|
|
154
|
-
// Wait for 2 seconds after click
|
|
155
|
-
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
156
|
-
return `Clicked on element with text: "${text}"`;
|
|
157
|
-
});
|
|
158
145
|
|
|
159
|
-
tool("mobile_list_elements_on_screen", "List elements on screen with display text or accessibility label. Do not cache this result.", {}, async ({}) => {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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
|
+
requireRobot();
|
|
148
|
+
const elements = await robot.getElementsOnScreen();
|
|
149
|
+
console.log(elements)
|
|
150
|
+
const result = elements.map(element => {
|
|
151
|
+
const out = {
|
|
152
|
+
type: element.type || null,
|
|
153
|
+
text: element.text || null,
|
|
154
|
+
label: element.label || null,
|
|
155
|
+
name: element.name || null,
|
|
156
|
+
value: element.value || null,
|
|
157
|
+
coordinates: {
|
|
158
|
+
x: element.rect.x || 0,
|
|
159
|
+
y: element.rect.y || 0,
|
|
160
|
+
width: element.rect.width || 0,
|
|
161
|
+
height: element.rect.height || 0,
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
if (element.focused) {
|
|
165
|
+
out.focused = true;
|
|
166
|
+
}
|
|
167
|
+
return out;
|
|
168
|
+
});
|
|
169
|
+
return `Found these elements on screen: ${JSON.stringify(result)}`;
|
|
174
170
|
});
|
|
175
|
-
|
|
176
|
-
});
|
|
171
|
+
|
|
177
172
|
tool("mobile_press_button", "Press a button on device", {
|
|
178
173
|
button: zod_1.z.string().describe("The button to press. Supported buttons: BACK (android only), HOME, VOLUME_UP, VOLUME_DOWN, ENTER, DPAD_CENTER (android tv only), DPAD_UP (android tv only), DPAD_DOWN (android tv only), DPAD_LEFT (android tv only), DPAD_RIGHT (android tv only)"),
|
|
179
174
|
}, async ({ button }) => {
|
|
@@ -257,7 +252,7 @@ tool(
|
|
|
257
252
|
|
|
258
253
|
|
|
259
254
|
tool(
|
|
260
|
-
"
|
|
255
|
+
"mobile_click",
|
|
261
256
|
"Click an element identified by text using path",
|
|
262
257
|
{
|
|
263
258
|
sessionId: zod_1.z.string().describe("Appium session ID"),
|