@nbakka/mcp-appium 4.0.6 → 4.0.8

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/android.js CHANGED
@@ -249,11 +249,24 @@ class AndroidRobot {
249
249
  const elements = this.collectElements(hierarchy.node);
250
250
  return elements;
251
251
  }
252
+ parseBounds(bounds) {
253
+ if (!bounds) return { x: 0, y: 0 };
254
+ const match = bounds.match(/\[(\d+),(\d+)\]/);
255
+ if (!match) return { x: 0, y: 0 };
256
+ return { x: parseInt(match[1]), y: parseInt(match[2]) };
257
+ }
252
258
  async getSimplifiedElements() {
253
259
  const parsedXml = await this.getUiAutomatorXml();
254
260
  const hierarchy = parsedXml.hierarchy;
255
261
  const elements = this.collectSimplifiedElements(hierarchy.node);
256
- return elements;
262
+
263
+ // Sort by visual position: top-to-bottom, left-to-right
264
+ return elements.sort((a, b) => {
265
+ const rectA = this.parseBounds(a.bounds);
266
+ const rectB = this.parseBounds(b.bounds);
267
+ if (rectA.y !== rectB.y) return rectA.y - rectB.y;
268
+ return rectA.x - rectB.x;
269
+ });
257
270
  }
258
271
  async terminateApp(packageName) {
259
272
  this.adb("shell", "am", "force-stop", packageName);
package/lib/server.js CHANGED
@@ -213,6 +213,12 @@ These are mandatory requirements - not suggestions.`;
213
213
  }
214
214
  );
215
215
 
216
+ tool("debug_dump_xml_structure", "DEBUG: Dump the raw parsed XML structure to see how fast-xml-parser creates the object", {}, async ({}) => {
217
+ requireRobot();
218
+ const structure = await robot.getXmlStructure();
219
+ return `Raw XML structure: ${JSON.stringify(structure, null, 2)}`;
220
+ });
221
+
216
222
  tool("mobile_list_elements_on_screen", "List elements on screen in a simplified, flattened structure. Returns only useful attributes: text, class, id (resource-id), accessibilityId (content-desc), and bounds. Do not cache this result.", {}, async ({}) => {
217
223
  requireRobot();
218
224
  const elements = await robot.getSimplifiedElements();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nbakka/mcp-appium",
3
- "version": "4.0.6",
3
+ "version": "4.0.8",
4
4
  "description": "Appium MCP",
5
5
  "engines": {
6
6
  "node": ">=18"