@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.
Files changed (2) hide show
  1. package/lib/server.js +26 -31
  2. 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
- requireRobot();
161
- const elements = await robot.getElementsOnScreen();
162
- const result = elements.map(element => {
163
- const out = {
164
- type: element.type,
165
- text: element.text,
166
- label: element.label,
167
- name: element.name,
168
- value: element.value,
169
- };
170
- if (element.focused) {
171
- out.focused = true;
172
- }
173
- return out;
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
- return `Found these elements on screen: ${JSON.stringify(result)}`;
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
- "mobile_click_using_xpath",
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"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nbakka/mcp-appium",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "Appium MCP",
5
5
  "engines": {
6
6
  "node": ">=18"