@nbakka/mcp-appium 2.0.2 → 2.0.3
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 +25 -31
- package/package.json +1 -1
package/lib/server.js
CHANGED
|
@@ -142,38 +142,32 @@ 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
|
-
|
|
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
|
+
const result = elements.map(element => {
|
|
150
|
+
const out = {
|
|
151
|
+
type: element.type,
|
|
152
|
+
text: element.text,
|
|
153
|
+
label: element.label,
|
|
154
|
+
name: element.name,
|
|
155
|
+
value: element.value,
|
|
156
|
+
coordinates: {
|
|
157
|
+
x: element.rect.x,
|
|
158
|
+
y: element.rect.y,
|
|
159
|
+
width: element.rect.width,
|
|
160
|
+
height: element.rect.height,
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
if (element.focused) {
|
|
164
|
+
out.focused = true;
|
|
165
|
+
}
|
|
166
|
+
return out;
|
|
167
|
+
});
|
|
168
|
+
return `Found these elements on screen: ${JSON.stringify(result)}`;
|
|
174
169
|
});
|
|
175
|
-
|
|
176
|
-
});
|
|
170
|
+
|
|
177
171
|
tool("mobile_press_button", "Press a button on device", {
|
|
178
172
|
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
173
|
}, async ({ button }) => {
|
|
@@ -257,7 +251,7 @@ tool(
|
|
|
257
251
|
|
|
258
252
|
|
|
259
253
|
tool(
|
|
260
|
-
"
|
|
254
|
+
"mobile_click",
|
|
261
255
|
"Click an element identified by text using path",
|
|
262
256
|
{
|
|
263
257
|
sessionId: zod_1.z.string().describe("Appium session ID"),
|