appium-mcp 1.95.8 → 1.97.0

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 (51) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +102 -2
  3. package/dist/command.d.ts +2 -0
  4. package/dist/command.d.ts.map +1 -1
  5. package/dist/command.js +12 -0
  6. package/dist/command.js.map +1 -1
  7. package/dist/tools/gestures/schema.d.ts.map +1 -1
  8. package/dist/tools/gestures/schema.js +3 -6
  9. package/dist/tools/gestures/schema.js.map +1 -1
  10. package/dist/tools/index.d.ts.map +1 -1
  11. package/dist/tools/index.js +2 -0
  12. package/dist/tools/index.js.map +1 -1
  13. package/dist/tools/interactions/find-elements.d.ts +3 -0
  14. package/dist/tools/interactions/find-elements.d.ts.map +1 -0
  15. package/dist/tools/interactions/find-elements.js +51 -0
  16. package/dist/tools/interactions/find-elements.js.map +1 -0
  17. package/dist/tools/interactions/find.d.ts.map +1 -1
  18. package/dist/tools/interactions/find.js +14 -18
  19. package/dist/tools/interactions/find.js.map +1 -1
  20. package/dist/tools/interactions/get-page-source.d.ts.map +1 -1
  21. package/dist/tools/interactions/get-page-source.js +12 -2
  22. package/dist/tools/interactions/get-page-source.js.map +1 -1
  23. package/dist/tools/interactions/page-source-file.d.ts +11 -0
  24. package/dist/tools/interactions/page-source-file.d.ts.map +1 -0
  25. package/dist/tools/interactions/page-source-file.js +18 -0
  26. package/dist/tools/interactions/page-source-file.js.map +1 -0
  27. package/dist/tools/interactions/page-source-summary.d.ts +9 -0
  28. package/dist/tools/interactions/page-source-summary.d.ts.map +1 -0
  29. package/dist/tools/interactions/page-source-summary.js +80 -0
  30. package/dist/tools/interactions/page-source-summary.js.map +1 -0
  31. package/dist/tools/tool-response.d.ts +2 -0
  32. package/dist/tools/tool-response.d.ts.map +1 -1
  33. package/dist/tools/tool-response.js +7 -0
  34. package/dist/tools/tool-response.js.map +1 -1
  35. package/dist/ui/page-source-inspector-app.d.ts.map +1 -1
  36. package/dist/ui/page-source-inspector-app.js +14 -0
  37. package/dist/ui/page-source-inspector-app.js.map +1 -1
  38. package/package.json +1 -1
  39. package/scripts/publish-mcp-registry.sh +31 -0
  40. package/server.json +2 -2
  41. package/src/command.ts +12 -0
  42. package/src/tools/README.md +11 -2
  43. package/src/tools/gestures/schema.ts +3 -8
  44. package/src/tools/index.ts +2 -0
  45. package/src/tools/interactions/find-elements.ts +61 -0
  46. package/src/tools/interactions/find.ts +23 -29
  47. package/src/tools/interactions/get-page-source.ts +14 -2
  48. package/src/tools/interactions/page-source-file.ts +20 -0
  49. package/src/tools/interactions/page-source-summary.ts +87 -0
  50. package/src/tools/tool-response.ts +8 -0
  51. package/src/ui/page-source-inspector-app.ts +14 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-source-file.d.ts","sourceRoot":"","sources":["../../../src/tools/interactions/page-source-file.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAM;;;GASjH"}
@@ -0,0 +1,18 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ import { mkdir, writeFile } from 'node:fs/promises';
3
+ import { tmpdir } from 'node:os';
4
+ import { join, resolve } from 'node:path';
5
+ import { summarizePageSource } from './page-source-summary.js';
6
+ /** Save a fresh XML snapshot and optionally summarize matching nodes.
7
+ * Invalid filters are evaluated before writing; filesystem errors propagate to the caller.
8
+ */
9
+ export async function savePageSourceToFile(pageSource, filters = {}) {
10
+ const { selector, pattern } = filters;
11
+ const summary = selector !== undefined || pattern !== undefined ? summarizePageSource(pageSource, selector, pattern) : {};
12
+ const directory = process.env.PAGE_SOURCES_DIR ? resolve(process.env.PAGE_SOURCES_DIR) : tmpdir();
13
+ await mkdir(directory, { recursive: true });
14
+ const filepath = join(directory, `page-source-${randomUUID()}.xml`);
15
+ await writeFile(filepath, pageSource, { encoding: 'utf8', mode: 0o600, flag: 'wx' });
16
+ return { filepath, bytes: Buffer.byteLength(pageSource, 'utf8'), ...summary };
17
+ }
18
+ //# sourceMappingURL=page-source-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-source-file.js","sourceRoot":"","sources":["../../../src/tools/interactions/page-source-file.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AACvC,OAAO,EAAC,KAAK,EAAE,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAC,MAAM,EAAC,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAC,IAAI,EAAE,OAAO,EAAC,MAAM,WAAW,CAAC;AAExC,OAAO,EAAC,mBAAmB,EAAC,MAAM,0BAA0B,CAAC;AAE7D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,UAAkB,EAAE,UAAiD,EAAE;IAChH,MAAM,EAAC,QAAQ,EAAE,OAAO,EAAC,GAAG,OAAO,CAAC;IACpC,MAAM,OAAO,GACX,QAAQ,KAAK,SAAS,IAAI,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,mBAAmB,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5G,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClG,MAAM,KAAK,CAAC,SAAS,EAAE,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;IAC1C,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,eAAe,UAAU,EAAE,MAAM,CAAC,CAAC;IACpE,MAAM,SAAS,CAAC,QAAQ,EAAE,UAAU,EAAE,EAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAC,CAAC,CAAC;IACnF,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,CAAC,UAAU,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,GAAG,OAAO,EAAC,CAAC;AAC9E,CAAC"}
@@ -0,0 +1,9 @@
1
+ /** Bounded node summaries; a pattern is a literal substring, never an executable expression. */
2
+ export declare function summarizePageSource(source: string, selector?: string, pattern?: string): {
3
+ matches: {
4
+ node: Record<string, string>;
5
+ visibleSiblings: Record<string, string>[];
6
+ }[];
7
+ truncated: boolean;
8
+ };
9
+ //# sourceMappingURL=page-source-summary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-source-summary.d.ts","sourceRoot":"","sources":["../../../src/tools/interactions/page-source-summary.ts"],"names":[],"mappings":"AAwCA,gGAAgG;AAChG,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;;;;;;EA6CtF"}
@@ -0,0 +1,80 @@
1
+ import { DOMParser } from '@xmldom/xmldom';
2
+ import xpath from 'xpath';
3
+ const MAX_NODES = 100;
4
+ const FIELDS = [
5
+ 'type',
6
+ 'class',
7
+ 'name',
8
+ 'label',
9
+ 'value',
10
+ 'text',
11
+ 'resource-id',
12
+ 'content-desc',
13
+ 'visible',
14
+ 'displayed',
15
+ 'bounds',
16
+ 'x',
17
+ 'y',
18
+ 'width',
19
+ 'height',
20
+ ];
21
+ function isElement(node) {
22
+ return typeof node === 'object' && node !== null && node.nodeType === 1;
23
+ }
24
+ function summarize(node) {
25
+ const result = {
26
+ type: node.getAttribute('type') || node.getAttribute('class') || node.tagName,
27
+ };
28
+ for (const field of FIELDS) {
29
+ const value = node.getAttribute(field);
30
+ if (value !== null) {
31
+ result[field] = value;
32
+ }
33
+ }
34
+ return result;
35
+ }
36
+ /** Bounded node summaries; a pattern is a literal substring, never an executable expression. */
37
+ export function summarizePageSource(source, selector, pattern) {
38
+ const document = new DOMParser({
39
+ onError: (level, message) => {
40
+ if (level !== 'warning') {
41
+ throw new Error(message);
42
+ }
43
+ },
44
+ }).parseFromString(source, 'text/xml');
45
+ const selection = xpath.select(selector || '//*', document);
46
+ if (!Array.isArray(selection) || selection.some((node) => !isElement(node))) {
47
+ throw new Error('selector must be an XPath selecting elements');
48
+ }
49
+ const selected = selection.filter((node) => pattern === undefined ||
50
+ [node.tagName, ...Array.from(node.attributes).map((attr) => attr.value)].some((value) => value.includes(pattern)));
51
+ let remaining = MAX_NODES;
52
+ let truncated = false;
53
+ const matches = [];
54
+ for (const node of selected) {
55
+ if (remaining === 0) {
56
+ truncated = true;
57
+ break;
58
+ }
59
+ remaining--;
60
+ const visibleSiblings = [];
61
+ for (const sibling of Array.from(node.parentNode?.childNodes ?? [])) {
62
+ if (!isElement(sibling) || sibling === node) {
63
+ continue;
64
+ }
65
+ const visible = sibling.getAttribute('visible') ?? sibling.getAttribute('displayed');
66
+ if (visible !== 'true' && visible !== '1') {
67
+ continue;
68
+ }
69
+ if (remaining === 0) {
70
+ truncated = true;
71
+ break;
72
+ }
73
+ remaining--;
74
+ visibleSiblings.push(summarize(sibling));
75
+ }
76
+ matches.push({ node: summarize(node), visibleSiblings });
77
+ }
78
+ return { matches, truncated };
79
+ }
80
+ //# sourceMappingURL=page-source-summary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page-source-summary.js","sourceRoot":"","sources":["../../../src/tools/interactions/page-source-summary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAEzC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,SAAS,GAAG,GAAG,CAAC;AACtB,MAAM,MAAM,GAAG;IACb,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;IACP,OAAO;IACP,MAAM;IACN,aAAa;IACb,cAAc;IACd,SAAS;IAC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AK,CAAC,EAAE,CAAC;gBACpB,SAAS,GAAG,IAAI,CAAC;gBACjB,MAAM;YACR,CAAC;YACD,SAAS,EAAE,CAAC;YACZ,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,EAAE,eAAe,EAAC,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,EAAC,OAAO,EAAE,SAAS,EAAC,CAAC;AAC9B,CAAC"}
@@ -16,6 +16,8 @@ export declare function toolErrorMessage(err: unknown): string;
16
16
  * or returns the value when the driver already returned a plain id string.
17
17
  */
18
18
  export declare function readWebElementId(element: unknown): string | undefined;
19
+ /** Additional driver fields, excluding duplicate protocol element IDs. */
20
+ export declare function readWebElementAttributes(element: unknown): Record<string, unknown>;
19
21
  /**
20
22
  * Standard success ContentResult.
21
23
  */
@@ -1 +1 @@
1
- {"version":3,"file":"tool-response.d.ts","sourceRoot":"","sources":["../../src/tools/tool-response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;AAK3C,OAAO,EAAwB,KAAK,cAAc,EAA2B,MAAM,qBAAqB,CAAC;AAMzG,MAAM,MAAM,aAAa,GAAG;IAAC,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,cAAc,CAAA;CAAC,GAAG;IAAC,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,aAAa,CAAA;CAAC,CAAC;AAEpG;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAErD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAUrE;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAEtD;AAED;;;GAGG;AACH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gB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAEtD;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,CAI/F;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAEvD;AAED,gGAAgG;AAChG,wBAAgB,4BAA4B,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAGvE;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,aAAa,CAE7E;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAgB9E;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,aAAa,CAEhG"}
@@ -25,6 +25,13 @@ export function readWebElementId(element) {
25
25
  const id = rec[W3C_ELEMENT_ID] ?? rec.ELEMENT;
26
26
  return typeof id === 'string' ? id : undefined;
27
27
  }
28
+ /** Additional driver fields, excluding duplicate protocol element IDs. */
29
+ export function readWebElementAttributes(element) {
30
+ if (element === null || typeof element !== 'object') {
31
+ return {};
32
+ }
33
+ return Object.fromEntries(Object.entries(element).filter(([key]) => key !== 'ELEMENT' && key !== W3C_ELEMENT_ID));
34
+ }
28
35
  /**
29
36
  * Standard success ContentResult.
30
37
  */
@@ -1 +1 @@
1
- {"version":3,"file":"tool-response.js","sourceRoot":"","sources":["../../src/tools/tool-response.ts"],"names":[],"mappings":"AAGA,OAAO,GAAG,MAAM,cAAc,CAAC;AAC/B,OAAO,EAAC,wBAAwB,EAAE,sBAAsB,EAAC,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAC,SAAS,EAAE,UAAU,EAAgD,MAAM,qBAAqB,CAAC;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C5F,GAAG,CAAC,IAAI,CAAC,+BAA+B,KAAK,CAAC,SAAS,wBAAwB,CAAC,CAAC;YACjF,OAAO,EAAC,SAAS,EAAE,KAAK,CAAC,SAAS,EAAC,CAAC;QACtC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,GAAG,CAAC,IAAI,CAAC,qBAAqB,KAAK,CAAC,SAAS,0BAA0B,gBAAgB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;YAC3G,MAAM,sBAAsB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,4BAA4B,CAAC,SAAiB;IACrD,OAAO,SAAS,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;AAClD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"page-source-inspector-app.d.ts","sourceRoot":"","sources":["../../src/ui/page-source-inspector-app.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,8BAA8B,IAAI,MAAM,CA6PvD"}
1
+ {"version":3,"file":"page-source-inspector-app.d.ts","sourceRoot":"","sources":["../../src/ui/page-source-inspector-app.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,8BAA8B,IAAI,MAAM,CA2QvD"}
@@ -117,6 +117,7 @@ export function createPageSourceInspectorAppUI() {
117
117
  const sourceInfo = document.getElementById('sourceInfo');
118
118
  const searchBox = document.getElementById('searchBox');
119
119
  let source = '';
120
+ let savedFile;
120
121
  let nextRequestId = 1;
121
122
  const pendingRequests = new Map();
122
123
 
@@ -131,6 +132,7 @@ export function createPageSourceInspectorAppUI() {
131
132
  }
132
133
 
133
134
  function sourceFromToolResult(result) {
135
+ savedFile = undefined;
134
136
  const textBlock = result && Array.isArray(result.content)
135
137
  ? result.content.find((item) => item && item.type === 'text' && typeof item.text === 'string')
136
138
  : undefined;
@@ -139,6 +141,13 @@ export function createPageSourceInspectorAppUI() {
139
141
  }
140
142
 
141
143
  let text = textBlock.text;
144
+ try {
145
+ const metadata = JSON.parse(text);
146
+ if (typeof metadata.filepath === 'string' && typeof metadata.bytes === 'number') {
147
+ savedFile = metadata;
148
+ return '';
149
+ }
150
+ } catch { /* Inline XML is not JSON. */ }
142
151
  if (text.startsWith(PAGE_SOURCE_PREFIX) && text.endsWith('\`\`\`')) {
143
152
  text = text.slice(PAGE_SOURCE_PREFIX.length, -3);
144
153
  }
@@ -170,6 +179,11 @@ export function createPageSourceInspectorAppUI() {
170
179
  const query = searchBox.value.trim();
171
180
  xmlContent.textContent = '';
172
181
  xmlContent.classList.toggle('empty', source.length === 0);
182
+ if (savedFile) {
183
+ sourceInfo.textContent = savedFile.bytes + ' bytes saved';
184
+ xmlContent.textContent = 'Saved on the MCP server: ' + savedFile.filepath + '\\nCall appium_get_page_source with saveToFile=false to inspect the XML here.';
185
+ return;
186
+ }
173
187
  if (!source) {
174
188
  xmlContent.textContent = 'No page source was returned.';
175
189
  } else if (!query) {
@@ -1 +1 @@
1
- {"version":3,"file":"page-source-inspector-app.js","sourceRoot":"","sources":["../../src/ui/page-source-inspector-app.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B;IAC5C,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2PN,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"page-source-inspector-app.js","sourceRoot":"","sources":["../../src/ui/page-source-inspector-app.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B;IAC5C,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyQN,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-mcp",
3
- "version": "1.95.8",
3
+ "version": "1.97.0",
4
4
  "description": "Intelligent MCP server providing AI assistants with powerful tools and resources for Appium mobile automation",
5
5
  "bugs": {
6
6
  "url": "https://github.com/appium/appium-mcp/issues"
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # npm can accept a release before the version is visible to MCP Registry.
5
+ # Retry the registry's version-not-found response for up to ten minutes.
6
+ max_attempts=21
7
+ retry_delay=30
8
+
9
+ for ((attempt = 1; attempt <= max_attempts; attempt++)); do
10
+ echo "Publishing to MCP Registry (attempt ${attempt}/${max_attempts})..."
11
+ if output=$(./mcp-publisher publish 2>&1); then
12
+ printf '%s\n' "$output"
13
+ exit 0
14
+ else
15
+ status=$?
16
+ fi
17
+ printf '%s\n' "$output" >&2
18
+
19
+ # Authentication, schema, and other errors need intervention, not retries.
20
+ if ! grep -Eq "NPM package '.*' exists, but version '.*' was not found \(status: 404\)" <<< "$output"; then
21
+ exit "$status"
22
+ fi
23
+
24
+ if ((attempt == max_attempts)); then
25
+ echo "npm version is still unavailable to MCP Registry after ${max_attempts} attempts." >&2
26
+ exit "$status"
27
+ fi
28
+
29
+ echo "Waiting ${retry_delay}s for npm propagation..."
30
+ sleep "$retry_delay"
31
+ done
package/server.json CHANGED
@@ -3,12 +3,12 @@
3
3
  "name": "io.github.appium/appium-mcp",
4
4
  "title": "MCP Appium - Mobile Development and Automation Server",
5
5
  "description": "MCP server for Appium mobile automation on iOS and Android devices with test creation tools.",
6
- "version": "1.95.8",
6
+ "version": "1.97.0",
7
7
  "packages": [
8
8
  {
9
9
  "registryType": "npm",
10
10
  "identifier": "appium-mcp",
11
- "version": "1.95.8",
11
+ "version": "1.97.0",
12
12
  "transport": {
13
13
  "type": "stdio"
14
14
  }
package/src/command.ts CHANGED
@@ -238,6 +238,18 @@ export async function findElement(driver: DriverInstance, strategy: string, sele
238
238
  return result;
239
239
  }
240
240
 
241
+ /** Find all matching elements, preserving driver-provided response attributes. */
242
+ export async function findElements(driver: DriverInstance, strategy: string, selector: string): Promise<unknown> {
243
+ if (isAndroidUiautomator2DriverSession(driver)) {
244
+ return await driver.findElements(strategy, selector);
245
+ } else if (isXCUITestDriverSession(driver)) {
246
+ return await driver.findElements(strategy, selector);
247
+ }
248
+ const result = await (driver as Client).findElements(strategy, selector);
249
+ throwIfSwallowedRemoteError(result);
250
+ return result;
251
+ }
252
+
241
253
  /**
242
254
  * Get the bounding rectangle for an element.
243
255
  *
@@ -29,7 +29,8 @@ This directory contains all MCP tools available in MCP Appium.
29
29
 
30
30
  ### Element Interactions (`interactions/`)
31
31
 
32
- - `find.ts` - Find elements
32
+ - `find.ts` - Find a single element
33
+ - `find-elements.ts` - Find all matching elements with driver-provided attributes
33
34
  - `click.ts` - Click elements
34
35
  - `double-tap.ts` - Double tap elements
35
36
  - `long-press.ts` - Long press (press and hold) elements
@@ -38,7 +39,9 @@ This directory contains all MCP tools available in MCP Appium.
38
39
  - `set-value.ts` - Enter text
39
40
  - `keyboard.ts` - Soft keyboard (`appium_mobile_keyboard`; `action=hide` \| `is_shown`)
40
41
  - `get-text.ts` - Get element text
41
- - `get-page-source.ts` - Get page source (XML) from current screen
42
+ - `get-page-source.ts` - Return current-screen XML by default; opt into server-local file output with `saveToFile: true`
43
+ - `page-source-file.ts` - Save fresh XML snapshots and return path, UTF-8 byte size, and optional summaries
44
+ - `page-source-summary.ts` - Build bounded XPath/literal-filter summaries with visible siblings
42
45
  - `screenshot.ts` - Capture screenshots
43
46
 
44
47
  #### Element Search Priority Order
@@ -212,3 +215,9 @@ After adding a new tool:
212
215
  - Read [docs/CONTRIBUTING.md](../../docs/CONTRIBUTING.md)
213
216
  - Look at examples in `examples/` directory
214
217
  - Open an issue for questions
218
+
219
+ ### Page source file output
220
+
221
+ `appium_get_page_source` keeps full XML and the existing inspector behavior when `saveToFile` is omitted or false. `saveToFile: true` delegates file creation and optional summary generation to `savePageSourceToFile`. The helper validates filters before writing, creates unique XML files with owner-only permissions under `PAGE_SOURCES_DIR` (or the OS temporary directory), and returns metadata; the tool serializes it into an MCP text response and handles errors.
222
+
223
+ `selector` and `pattern` require `saveToFile: true`. They limit the returned summary, not the saved XML. Each call obtains fresh XML from the driver; this is file-backed snapshot storage, not response reuse. `NO_UI` controls UI resources independently. See [page source file output and filtered summaries](../../README.md#page-source-file-output-and-filtered-summaries) for arguments and usage examples.
@@ -73,20 +73,15 @@ export const gestureSchema = z.object({
73
73
  .min(0)
74
74
  .optional()
75
75
  .describe(
76
- 'X coordinate in pixels. For tap/double_tap/long_press: tap location, paired with y. ' +
77
- 'For scroll/swipe: starting X in custom-coordinate mode; requires y, endX, endY. ' +
78
- 'For pinch_zoom: center X, paired with y. Tap/double_tap/long_press/pinch_zoom ignore x/y when elementUUID is set.',
76
+ 'X pixel coordinate, paired with y: tap location, pinch center, or scroll/swipe start (requires endX/endY). ' +
77
+ 'elementUUID overrides x/y for tap/double_tap/long_press/pinch_zoom.',
79
78
  ),
80
79
  y: z
81
80
  .number()
82
81
  .int()
83
82
  .min(0)
84
83
  .optional()
85
- .describe(
86
- 'Y coordinate in pixels, paired with x. For tap/double_tap/long_press: tap location. ' +
87
- 'For scroll/swipe: starting Y in custom-coordinate mode. For pinch_zoom: center Y. ' +
88
- 'The same elementUUID precedence as x applies.',
89
- ),
84
+ .describe('Y pixel coordinate, paired with x; same action meanings and elementUUID precedence as x.'),
90
85
  endX: z
91
86
  .number()
92
87
  .int()
@@ -26,6 +26,7 @@ import gesture from './gestures/gesture.js';
26
26
  import performActionsTool from './gestures/perform-actions.js';
27
27
  import getActiveElement from './interactions/active-element.js';
28
28
  import clipboard from './interactions/clipboard.js';
29
+ import findElements from './interactions/find-elements.js';
29
30
  import findElement from './interactions/find.js';
30
31
  import getElementAttribute from './interactions/get-element-attribute.js';
31
32
  import getPageSource from './interactions/get-page-source.js';
@@ -120,6 +121,7 @@ export default function registerTools(server: FastMCP): void {
120
121
  // 2. findElement - Find specific element by strategy/selector
121
122
  // 3. generateLocators - Generate all locators (heavyweight, for debugging only)
122
123
  findElement(server);
124
+ findElements(server);
123
125
  pressKey(server);
124
126
  setValue(server);
125
127
  keyboard(server);
@@ -0,0 +1,61 @@
1
+ import type {ContentResult, FastMCP} from 'fastmcp';
2
+ import type {z} from 'zod';
3
+
4
+ import {findElements as findMatchingElements} from '../../command.js';
5
+ import {evidenceContext, withEvidence} from '../evidence.js';
6
+ import {
7
+ errorResult,
8
+ readWebElementAttributes,
9
+ readWebElementId,
10
+ resolveDriver,
11
+ textResult,
12
+ toolErrorMessage,
13
+ } from '../tool-response.js';
14
+ import {findElementSchema} from './find.js';
15
+
16
+ export default function findElements(server: FastMCP): void {
17
+ server.addTool({
18
+ name: 'appium_find_elements',
19
+ description:
20
+ 'Find all elements matching a strategy and selector. Returns JSON {elements: [{elementId, attributes?}]}; ' +
21
+ 'no matches returns {elements: []}. Pass an elementId as elementUUID to interaction tools. ' +
22
+ 'Additional driver attributes are preserved. For drivers supporting elementResponseAttributes, use ' +
23
+ 'appium_driver_settings to configure it with shouldUseCompactResponses=false. ' +
24
+ 'Use appium_find_element when only one match is needed.',
25
+ parameters: findElementSchema,
26
+ annotations: {readOnlyHint: true, openWorldHint: false},
27
+ execute: async (args: z.infer<typeof findElementSchema>): Promise<ContentResult> => {
28
+ const resolved = await resolveDriver(args.sessionId);
29
+ if (!resolved.ok) {
30
+ return resolved.result;
31
+ }
32
+ const evidence = {
33
+ name: 'appium_find_elements',
34
+ stage: 'locate' as const,
35
+ startedAt: Date.now(),
36
+ locator: {strategy: args.strategy, selector: args.selector},
37
+ context: await evidenceContext(args.sessionId),
38
+ };
39
+ try {
40
+ const result = await findMatchingElements(resolved.driver, args.strategy, args.selector);
41
+ if (!Array.isArray(result)) {
42
+ throw new Error('Driver returned a non-array findElements response');
43
+ }
44
+ const elements = result.map((element) => {
45
+ const elementId = readWebElementId(element);
46
+ if (!elementId) {
47
+ throw new Error('Element was returned without a valid element ID');
48
+ }
49
+ const attributes = readWebElementAttributes(element);
50
+ return Object.keys(attributes).length > 0 ? {elementId, attributes} : {elementId};
51
+ });
52
+ return withEvidence(textResult(JSON.stringify({elements})), evidence);
53
+ } catch (error: unknown) {
54
+ return withEvidence(errorResult(`Failed to find elements. Error: ${toolErrorMessage(error)}`), {
55
+ ...evidence,
56
+ error,
57
+ });
58
+ }
59
+ },
60
+ });
61
+ }
@@ -9,6 +9,7 @@ import {
9
9
  errorResult,
10
10
  toolErrorMessage,
11
11
  readWebElementId,
12
+ readWebElementAttributes,
12
13
  } from '../tool-response.js';
13
14
 
14
15
  export const findElementSchema = z.object({
@@ -26,24 +27,15 @@ export const findElementSchema = z.object({
26
27
  ])
27
28
  .describe(
28
29
  [
29
- 'Locator strategy. Prefer stable identifiers, then platform-native queries; xpath is the last resort.',
30
- '- accessibility id: cross-platform, fast and stable when available.',
31
- '- id: Android resource-id; an accessibility-id alias on iOS.',
32
- '- -ios predicate string: fast native iOS queries on element attributes.',
33
- '- -ios class chain: native iOS hierarchy queries.',
34
- '- -android uiautomator: native Android queries using UiSelector.',
35
- '- xpath: last resort; slow on iOS XCUITest and brittle to layout changes.',
36
- '- name: legacy; often aliased on iOS.',
37
- '- class name: usually too generic and may match multiple elements.',
38
- '- css selector: webview/hybrid web contexts only, not native screens.',
39
- 'iOS prefer accessibility id > -ios predicate string > -ios class chain; Android prefer accessibility id > id > -android uiautomator. Use xpath last on both.',
30
+ 'accessibility id: cross-platform, fast and stable. id: Android resource-id; iOS accessibility-id alias.',
31
+ 'iOS prefer accessibility id > -ios predicate string > -ios class chain; Android prefer accessibility id > id > -android uiautomator. Use xpath last (slow/brittle).',
32
+ 'name: legacy; class name: broad matches; css selector: webview only.',
40
33
  ].join('\n'),
41
34
  ),
42
35
  selector: z
43
36
  .string()
44
37
  .describe(
45
- 'Selector string for the chosen strategy. Do not pass natural-language descriptions of the target here; ' +
46
- 'use appium_ai action=find_element if enabled for vision-based finding.',
38
+ 'Selector for the strategy. Do not pass natural-language descriptions; use appium_ai action=find_element for vision.',
47
39
  ),
48
40
  sessionId: z.string().optional().describe('Session ID; defaults to the active session.'),
49
41
  });
@@ -52,11 +44,11 @@ export default function findElement(server: FastMCP): void {
52
44
  server.addTool({
53
45
  name: 'appium_find_element',
54
46
  description: [
55
- 'Find an element by strategy and selector; the primary tool for locating a specific target. Returns its ID for interactions. ' +
56
- 'Pass that ID as elementUUID to interaction tools.',
47
+ 'Find an element by strategy and selector. Pass its ID as elementUUID to interaction tools. Returns driver attributes as JSON. ' +
48
+ 'For drivers supporting elementResponseAttributes, use appium_driver_settings to configure it with shouldUseCompactResponses=false.',
57
49
  'Prefer accessibility id > id > platform-native > xpath (last resort: slow/brittle). See strategy for platform-specific guidance.',
58
50
  'To scroll until a target is found, use appium_gesture action=scroll_to_element with the same strategy and selector, rather than repeatedly calling this tool.',
59
- 'For natural-language/vision finding, use appium_ai action=find_element if enabled and stable locators do not work.',
51
+ 'Vision fallback: appium_ai action=find_element (if enabled).',
60
52
  ].join('\n'),
61
53
  parameters: findElementSchema,
62
54
  annotations: {
@@ -88,20 +80,22 @@ export default function findElement(server: FastMCP): void {
88
80
  context,
89
81
  });
90
82
  }
91
- return withEvidence(
92
- textResultWithPrimaryElementId(
93
- elementId,
94
- `Successfully found element ${args.selector} with strategy ${args.strategy}.`,
95
- ),
96
- {
97
- name: 'appium_find_element',
98
- stage: 'locate',
99
- startedAt,
100
- locator,
101
- element: {webdriverId: elementId},
102
- context,
103
- },
83
+ const response = textResultWithPrimaryElementId(
84
+ elementId,
85
+ `Successfully found element ${args.selector} with strategy ${args.strategy}.`,
104
86
  );
87
+ const attributes = readWebElementAttributes(element);
88
+ if (Object.keys(attributes).length > 0) {
89
+ response.content.push({type: 'text', text: JSON.stringify({elementId, attributes})});
90
+ }
91
+ return withEvidence(response, {
92
+ name: 'appium_find_element',
93
+ stage: 'locate',
94
+ startedAt,
95
+ locator,
96
+ element: {webdriverId: elementId},
97
+ context,
98
+ });
105
99
  } catch (err: unknown) {
106
100
  return withEvidence(errorResult(`Failed to find element. Error: ${toolErrorMessage(err)}`), {
107
101
  name: 'appium_find_element',
@@ -6,19 +6,24 @@ import {PAGE_SOURCE_INSPECTOR_URI} from '../../resources/page-source-inspector.j
6
6
  import {clientSupportsMcpApps, isMcpAppsEnabled} from '../../ui/mcp-apps.js';
7
7
  import {createUIResource, createPageSourceInspectorUI, addUIResourceToResponse} from '../../ui/mcp-ui-utils.js';
8
8
  import {resolveDriver, textResult, errorResult, toolErrorMessage} from '../tool-response.js';
9
+ import {savePageSourceToFile} from './page-source-file.js';
9
10
 
10
11
  export default function getPageSource(server: FastMCP): void {
11
12
  const mcpAppsEnabled = isMcpAppsEnabled();
12
13
  const pageSourceSchema = z.object({
14
+ saveToFile: z.boolean().default(false).describe('Save fresh XML to a file; return path/bytes instead of XML.'),
15
+ selector: z.string().optional().describe('XPath selecting elements.'),
16
+ pattern: z.string().min(1).optional().describe('Literal tag/attribute substring.'),
13
17
  sessionId: z.string().optional().describe('Session ID; defaults to the active session.'),
14
18
  });
15
19
  server.addTool({
16
20
  name: 'appium_get_page_source',
17
- description: 'Get the page source (XML) from the current screen',
21
+ description:
22
+ 'Get current-screen XML. saveToFile=true returns server-local path/bytes and enables selector/pattern summaries.',
18
23
  _meta: mcpAppsEnabled ? {ui: {resourceUri: PAGE_SOURCE_INSPECTOR_URI}} : undefined,
19
24
  parameters: pageSourceSchema,
20
25
  annotations: {
21
- readOnlyHint: true,
26
+ readOnlyHint: false,
22
27
  openWorldHint: false,
23
28
  },
24
29
  execute: async (
@@ -37,6 +42,13 @@ export default function getPageSource(server: FastMCP): void {
37
42
  return errorResult('Page source is empty or null');
38
43
  }
39
44
 
45
+ if (args.saveToFile === true) {
46
+ return textResult(JSON.stringify(await savePageSourceToFile(pageSource, args)));
47
+ }
48
+ if (args.selector !== undefined || args.pattern !== undefined) {
49
+ return errorResult('Use saveToFile=true when selecting or filtering page source nodes.');
50
+ }
51
+
40
52
  const textResponse = textResult('Page source retrieved successfully: \n' + '```xml ' + pageSource + '```');
41
53
 
42
54
  // MCP Apps-capable clients fetch the static inspector once and pass
@@ -0,0 +1,20 @@
1
+ import {randomUUID} from 'node:crypto';
2
+ import {mkdir, writeFile} from 'node:fs/promises';
3
+ import {tmpdir} from 'node:os';
4
+ import {join, resolve} from 'node:path';
5
+
6
+ import {summarizePageSource} from './page-source-summary.js';
7
+
8
+ /** Save a fresh XML snapshot and optionally summarize matching nodes.
9
+ * Invalid filters are evaluated before writing; filesystem errors propagate to the caller.
10
+ */
11
+ export async function savePageSourceToFile(pageSource: string, filters: {selector?: string; pattern?: string} = {}) {
12
+ const {selector, pattern} = filters;
13
+ const summary =
14
+ selector !== undefined || pattern !== undefined ? summarizePageSource(pageSource, selector, pattern) : {};
15
+ const directory = process.env.PAGE_SOURCES_DIR ? resolve(process.env.PAGE_SOURCES_DIR) : tmpdir();
16
+ await mkdir(directory, {recursive: true});
17
+ const filepath = join(directory, `page-source-${randomUUID()}.xml`);
18
+ await writeFile(filepath, pageSource, {encoding: 'utf8', mode: 0o600, flag: 'wx'});
19
+ return {filepath, bytes: Buffer.byteLength(pageSource, 'utf8'), ...summary};
20
+ }