appium-mcp 1.97.2 → 1.98.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [1.98.0](https://github.com/appium/appium-mcp/compare/v1.97.2...v1.98.0) (2026-10-25)
2
+
3
+ ### Features
4
+
5
+ * Fix some UI behavior for the page source, adds format ([#589](https://github.com/appium/appium-mcp/issues/589)) ([0ff11a1](https://github.com/appium/appium-mcp/commit/0ff11a1343880e3af9985a3c39e8396814dc34e5))
6
+
1
7
  ## [1.97.2](https://github.com/appium/appium-mcp/compare/v1.97.1...v1.97.2) (2026-10-25)
2
8
 
3
9
  ### Miscellaneous Chores
package/README.md CHANGED
@@ -198,7 +198,9 @@ This will automatically configure the MCP server for use with Claude Code. Make
198
198
  | `APPIUM_MCP_OTEL_ENABLED` | Optional | Set to `true` to enable OpenTelemetry tracing (disabled by default). |
199
199
  | `APPIUM_MCP_OTEL_INCLUDE_ARGUMENT_VALUES` | Optional | Set to `true` to include sanitized non-sensitive argument values in spans; disabled by default because values may contain sensitive data. |
200
200
  | `OTEL_SERVICE_NAME` | Optional | Service name reported to the OpenTelemetry collector (example: `appium-mcp`). |
201
- | `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` | Optional | OTLP/HTTP traces endpoint (example: `http://127.0.0.1:4318/v1/traces`). |
201
+ | `OTEL_EXPORTER_OTLP_PROTOCOL` | Optional | Trace export protocol: `http/json` (default) or `grpc`. |
202
+ | `OTEL_EXPORTER_OTLP_TRACES_PROTOCOL` | Optional | Trace-specific protocol; overrides `OTEL_EXPORTER_OTLP_PROTOCOL`. Supports `http/json` or `grpc`. |
203
+ | `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` | Optional | Traces endpoint. HTTP/JSON: `https://collector.example.com/v1/traces`; gRPC: `https://collector.example.com:443` (no `/v1/traces`). Overrides `OTEL_EXPORTER_OTLP_ENDPOINT`. |
202
204
  | `OTEL_TRACES_SAMPLER` | Optional | Trace sampling strategy; `parentbased_always_on` samples new root traces and follows parent decisions. |
203
205
  | `OTEL_RESOURCE_ATTRIBUTES` | Optional | Comma-separated `key=value` pairs attached as resource attributes to every span (example: `testcase.id=my-test-123,team=platform`). |
204
206
 
@@ -230,7 +232,28 @@ OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://127.0.0.1:4318/v1/traces
230
232
  OTEL_TRACES_SAMPLER=parentbased_always_on
231
233
  ```
232
234
 
233
- (Please check the [official document](https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/) as well)
235
+ The default remains OTLP HTTP/JSON. To use OTLP/gRPC with TLS:
236
+
237
+ ```bash
238
+ APPIUM_MCP_OTEL_ENABLED=true \
239
+ OTEL_SERVICE_NAME=appium-mcp \
240
+ OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=grpc \
241
+ OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=https://collector.example.com:443 \
242
+ npm run start:stdio
243
+ ```
244
+
245
+ For a local gRPC collector without TLS, use `http://127.0.0.1:4317`. gRPC endpoints must not include
246
+ `/v1/traces`; HTTP/JSON trace endpoints should include that path (or the receiver's configured path).
247
+ Both exporters accept `https://` for TLS. The receiver must support the selected protocol and encoding.
248
+
249
+ `OTEL_EXPORTER_OTLP_TRACES_PROTOCOL` takes precedence over `OTEL_EXPORTER_OTLP_PROTOCOL`; empty values
250
+ are treated as unset. Unsupported protocols, including `http/protobuf`, produce an initialization error
251
+ when tracing is enabled. Endpoint, headers, timeout, and TLS configuration are handled by the selected
252
+ OpenTelemetry exporter. For example, use `OTEL_EXPORTER_OTLP_TRACES_HEADERS` for authentication metadata,
253
+ and `OTEL_EXPORTER_OTLP_TRACES_CERTIFICATE` for a custom gRPC CA certificate file.
254
+
255
+ See the [OpenTelemetry environment variable documentation](https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/)
256
+ and [gRPC exporter documentation](https://open-telemetry.github.io/opentelemetry-js/modules/_opentelemetry_exporter-trace-otlp-grpc.html).
234
257
 
235
258
  When enabled, appium-mcp creates spans for MCP tool calls, prompt loads, resource reads, and resource template reads. Error status is recorded for thrown operation errors and MCP tool results marked with `isError`. Span attributes intentionally avoid raw screenshots, XML page source, prompts, credentials, and other high-cardinality or sensitive payloads.
236
259
 
@@ -3,6 +3,8 @@
3
3
  * via APPIUM_MCP_OTEL_ENABLED so normal server startup keeps the default no-op
4
4
  * OpenTelemetry provider and avoids exporter setup unless tracing is requested.
5
5
  */
6
+ /** Resolve trace-specific configuration before the general OTLP setting. */
7
+ export declare function getTraceExportProtocol(): 'http/json' | 'grpc';
6
8
  /**
7
9
  * Initializes the OpenTelemetry SDK if telemetry is enabled and not already started.
8
10
  * This function is idempotent and safe to call multiple times; the SDK will only
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/telemetry/init.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH;;;;;GAKG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CAmB7D;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAW3D"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/telemetry/init.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AASH,4EAA4E;AAC5E,wBAAgB,sBAAsB,IAAI,WAAW,GAAG,MAAM,CAW7D;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,IAAI,CAAC,CAsB7D;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAW3D"}
@@ -8,6 +8,16 @@ import { isTelemetryEnabled } from './attributes.js';
8
8
  let sdkStarted = false;
9
9
  let shutdownRegistered = false;
10
10
  let sdk;
11
+ /** Resolve trace-specific configuration before the general OTLP setting. */
12
+ export function getTraceExportProtocol() {
13
+ const protocol = process.env.OTEL_EXPORTER_OTLP_TRACES_PROTOCOL?.trim() ||
14
+ process.env.OTEL_EXPORTER_OTLP_PROTOCOL?.trim() ||
15
+ 'http/json';
16
+ if (protocol !== 'http/json' && protocol !== 'grpc') {
17
+ throw new Error('Unsupported OTLP trace protocol. Use http/json or grpc in OTEL_EXPORTER_OTLP_TRACES_PROTOCOL or OTEL_EXPORTER_OTLP_PROTOCOL.');
18
+ }
19
+ return protocol;
20
+ }
11
21
  /**
12
22
  * Initializes the OpenTelemetry SDK if telemetry is enabled and not already started.
13
23
  * This function is idempotent and safe to call multiple times; the SDK will only
@@ -18,9 +28,12 @@ export async function initializeOpenTelemetry() {
18
28
  if (!isTelemetryEnabled() || sdkStarted) {
19
29
  return;
20
30
  }
31
+ const protocol = getTraceExportProtocol();
21
32
  const [{ NodeSDK }, { OTLPTraceExporter }] = await Promise.all([
22
33
  import('@opentelemetry/sdk-node'),
23
- import('@opentelemetry/exporter-trace-otlp-http'),
34
+ protocol === 'grpc'
35
+ ? import('@opentelemetry/exporter-trace-otlp-grpc')
36
+ : import('@opentelemetry/exporter-trace-otlp-http'),
24
37
  ]);
25
38
  const nodeSdk = new NodeSDK({
26
39
  traceExporter: new OTLPTraceExporter(),
@@ -1 +1 @@
1
- {"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/telemetry/init.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,GAAG,MAAM,cAAc,CAAC;AAC/B,OAAO,EAAC,kBAAkB,EAAC,MAAM,iBAAiB,CAAC;AAEnD,IAAI,UAAU,GAAG,KAAK,CAAC;AACvB,IAAI,kBAAkB,GAAG,KAAK,CAAC;AAC/B,IAAI,GAA2D,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB;IAC3C,IAAI,CAAC,kBAAkB,EAAE,IAAI,UAAU,EAAE,CAAC;QACxC,OAAO;IACT,CAAC;IAED,MAAM,CAAC,EAAC,OAAO,EAAC,EAAE,EAAC,iBAAiB,E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AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAe,GAAG,MAAM,CAyJtF;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE;IAAC,OAAO,EAAE,KAAK,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAC,CAAC,CAAA;CAAC,EACzD,UAAU,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,GAAG,CAAC,MAAM,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC,GAC5F;IAAC,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;CAAC,CAUvB"}
@@ -877,7 +877,7 @@ export function createPageSourceInspectorUI(pageSource) {
877
877
  background: #1e1e1e;
878
878
  color: #d4d4d4;
879
879
  padding: 0;
880
- overflow: hidden;
880
+ overflow: auto;
881
881
  }
882
882
  summary {
883
883
  padding: 12px 16px;
@@ -924,7 +924,9 @@ export function createPageSourceInspectorUI(pageSource) {
924
924
  color: #999;
925
925
  }
926
926
  .viewer {
927
- max-height: 320px;
927
+ height: 320px;
928
+ min-height: 160px;
929
+ resize: vertical;
928
930
  overflow: auto;
929
931
  padding: 16px;
930
932
  }
@@ -973,7 +975,7 @@ export function createPageSourceInspectorUI(pageSource) {
973
975
  <button class="btn" onclick="generateLocators()">Generate Locators</button>
974
976
  </div>
975
977
  </div>
976
- <div class="viewer">
978
+ <div class="viewer" title="Drag the bottom-right corner to resize vertically">
977
979
  <pre class="xml-content" id="xmlContent">${escapedSource}</pre>
978
980
  </div>
979
981
  </details>
@@ -986,13 +988,46 @@ export function createPageSourceInspectorUI(pageSource) {
986
988
  }
987
989
 
988
990
  function formatXML() {
989
- const content = document.getElementById('xmlContent').textContent;
990
991
  try {
991
992
  const parser = new DOMParser();
992
- const xmlDoc = parser.parseFromString(content, 'text/xml');
993
+ const xmlDoc = parser.parseFromString(originalSource, 'text/xml');
994
+ if (!xmlDoc.documentElement || xmlDoc.getElementsByTagName('parsererror').length) {
995
+ throw new Error('Invalid XML');
996
+ }
997
+
998
+ function indentElement(element, depth) {
999
+ // Do not introduce whitespace into mixed content or preserved subtrees.
1000
+ if (element.getAttribute('xml:space') === 'preserve') return;
1001
+ const children = Array.from(element.childNodes);
1002
+ if (children.some(child =>
1003
+ child.nodeType === 4 || (child.nodeType === 3 && child.nodeValue.trim())
1004
+ )) return;
1005
+ if (!children.some(child => child.nodeType === 1)) return;
1006
+
1007
+ for (const child of children) {
1008
+ if (child.nodeType === 3) {
1009
+ element.removeChild(child);
1010
+ continue;
1011
+ }
1012
+ if (child.nodeType === 1) indentElement(child, depth + 1);
1013
+ element.insertBefore(xmlDoc.createTextNode('\\n' + ' '.repeat(depth + 1)), child);
1014
+ }
1015
+ element.appendChild(xmlDoc.createTextNode('\\n' + ' '.repeat(depth)));
1016
+ }
1017
+
1018
+ indentElement(xmlDoc.documentElement, 0);
993
1019
  const serializer = new XMLSerializer();
994
- const formatted = serializer.serializeToString(xmlDoc);
995
- document.getElementById('xmlContent').textContent = formatted;
1020
+ let formatted = Array.from(xmlDoc.childNodes)
1021
+ .filter(node => node.nodeType !== 3)
1022
+ .map(node => serializer.serializeToString(node))
1023
+ .join('\\n');
1024
+ // Browser DOMParser does not retain the XML declaration.
1025
+ const declaration = originalSource.match(/^\\s*(<\\?xml\\s[^?]*\\?>)/);
1026
+ if (declaration && !formatted.startsWith('<?xml ')) {
1027
+ formatted = declaration[1] + '\\n' + formatted;
1028
+ }
1029
+ displayedSource = formatted;
1030
+ renderSource(document.getElementById('searchBox').value);
996
1031
  } catch (e) {
997
1032
  alert('Failed to format XML');
998
1033
  }
@@ -1010,6 +1045,7 @@ export function createPageSourceInspectorUI(pageSource) {
1010
1045
 
1011
1046
  const xmlContent = document.getElementById('xmlContent');
1012
1047
  const originalSource = xmlContent.textContent;
1048
+ let displayedSource = originalSource;
1013
1049
 
1014
1050
  function appendTextWithHighlights(container, text, searchTerm) {
1015
1051
  const searchLower = searchTerm.toLowerCase();
@@ -1041,11 +1077,11 @@ export function createPageSourceInspectorUI(pageSource) {
1041
1077
  function renderSource(searchTerm = '') {
1042
1078
  xmlContent.textContent = '';
1043
1079
  if (!searchTerm) {
1044
- xmlContent.textContent = originalSource;
1080
+ xmlContent.textContent = displayedSource;
1045
1081
  return;
1046
1082
  }
1047
1083
 
1048
- appendTextWithHighlights(xmlContent, originalSource, searchTerm);
1084
+ appendTextWithHighlights(xmlContent, displayedSource, searchTerm);
1049
1085
  }
1050
1086
 
1051
1087
  // Search functionality
@@ -1 +1 @@
1
- {"version":3,"file":"mcp-ui-utils.js","sourceRoot":"","sources":["../../src/ui/mcp-ui-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAW,EACX,WAAmB;IASnB,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE;YACR,GAAG;YACH,QAAQ,EAAE,WAAW;YACrB,IAAI,EAAE,WAAW;SAClB;KACF,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAKE,EACF,QAA2B,EAC3B,UAAiC;IAEjC,MAAM,eAAe,GACnB,QAAQ,KAAK,KAAK,IAAI,UAAU;QAC9B,CAAC,CAAC,UAAU,KAAK,WAAW;YAC1B,CAAC,CAAC,gBAAgB;YAClB,CAAC,CAAC,aAAa;QACjB,CAAC,CAAC,iBAAiB,CAAC;IAExB,MAAM,WAAW,GAAG,OAAO;SACxB,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QACrB,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACjC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC;QACjC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,M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AE;SACb,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC;SAC7B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAC3B,CAAC;AACJ,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,CA2QvD"}
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,CAsVvD"}
@@ -13,102 +13,72 @@ export function createPageSourceInspectorAppUI() {
13
13
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
14
14
  <title>Page Source Inspector</title>
15
15
  <style>
16
+ :root { color-scheme: dark; --bg: #17191d; --panel: #202329; --line: #343941; --text: #e5e8ee; --muted: #a3acba; --accent: #91baff; }
16
17
  * { box-sizing: border-box; }
17
- body {
18
- margin: 0;
19
- overflow: hidden;
20
- background: #1e1e1e;
21
- color: #d4d4d4;
22
- font-family: Monaco, Menlo, "Courier New", monospace;
23
- }
24
- summary {
25
- padding: 12px 16px;
26
- background: #2d2d2d;
27
- cursor: pointer;
28
- font-size: 14px;
29
- }
30
- summary .info { margin-left: 8px; }
31
- .toolbar {
32
- display: flex;
33
- flex-wrap: wrap;
34
- align-items: center;
35
- justify-content: space-between;
36
- gap: 12px;
37
- padding: 12px 16px;
38
- border-bottom: 1px solid #3e3e3e;
39
- background: #2d2d2d;
40
- }
41
- .toolbar-right {
42
- flex-wrap: wrap;
43
- display: flex;
44
- align-items: center;
45
- gap: 8px;
46
- }
47
- .title { font-size: 14px; font-weight: 500; }
48
- .info { color: #999; font-size: 12px; }
49
- .btn {
50
- padding: 6px 12px;
51
- border: 0;
52
- border-radius: 4px;
53
- background: #007aff;
54
- color: #fff;
55
- cursor: pointer;
56
- font: 13px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
57
- }
58
- .btn:hover { background: #0056b3; }
59
- .btn-secondary { background: #444; }
60
- .btn-secondary:hover { background: #555; }
61
- .search-box {
62
- width: 200px;
63
- padding: 6px 12px;
64
- border: 1px solid #555;
65
- border-radius: 4px;
66
- outline: none;
67
- background: #3e3e3e;
68
- color: #d4d4d4;
69
- font-size: 13px;
70
- }
71
- .search-box:focus { border-color: #007aff; }
72
- .viewer {
73
- max-height: 320px;
74
- overflow: auto;
75
- padding: 16px;
76
- }
77
- .xml-content {
78
- margin: 0;
79
- white-space: pre;
80
- color: #d4d4d4;
81
- font-size: 13px;
82
- line-height: 1.6;
83
- }
84
- mark {
85
- border-radius: 2px;
86
- background: #ffd54f;
87
- color: #1e1e1e;
88
- }
89
- .empty {
90
- color: #999;
91
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
92
- }
18
+ [hidden] { display: none !important; }
19
+ body { margin: 0; overflow: auto; background: var(--bg); color: var(--text); font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
20
+ summary { cursor: pointer; padding: 16px 20px; }
21
+ summary::marker { color: var(--muted); }
22
+ .title { font-size: 15px; font-weight: 600; letter-spacing: -.2px; }
23
+ .info { color: var(--muted); font-size: 12px; margin-left: 10px; }
24
+ .toolbar, .section-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
25
+ .toolbar { padding: 12px 20px; border-block: 1px solid var(--line); background: var(--panel); }
26
+ .toolbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
27
+ .btn { padding: 8px 12px; border: 1px solid transparent; border-radius: 7px; background: #a7c7ff; color: #14243d; cursor: pointer; font: inherit; font-weight: 600; }
28
+ .btn:hover { background: #c2d8ff; }
29
+ .btn:disabled { opacity: .55; cursor: wait; }
30
+ .btn-secondary { background: transparent; border-color: #48505d; color: var(--text); }
31
+ .btn-secondary:hover { background: #303641; }
32
+ .btn:focus-visible, summary:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
33
+ .search-box { width: min(240px, 100%); min-width: 0; padding: 8px 12px; border: 1px solid #48505d; border-radius: 7px; background: var(--bg); color: var(--text); font: inherit; }
34
+ .search-box::placeholder { color: var(--muted); }
35
+ .viewer { height: 320px; min-height: 160px; resize: vertical; overflow: auto; padding: 20px; }
36
+ .xml-content, .selector { margin: 0; font: 12px/1.75 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
37
+ .xml-content { white-space: pre; color: #c5d3e7; }
38
+ mark { border-radius: 3px; background: #eac77a; color: #252019; }
39
+ .empty, .hint { color: var(--muted); }
40
+ .empty { font-family: inherit; }
41
+ .hint { margin: 6px 0 0; font-size: 12px; }
42
+ .locators { border-top: 1px solid var(--line); padding: 20px; }
43
+ h2 { margin: 0; font-size: 14px; font-weight: 600; }
44
+ #locatorStatus { margin: 16px 0 10px; color: var(--accent); font-size: 12px; }
45
+ .locator-results { max-height: 480px; overflow: auto; }
46
+ .locator-card { margin: 8px 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); overflow: hidden; }
47
+ .locator-card summary { padding: 12px 14px; overflow-wrap: anywhere; }
48
+ .element-type { margin-left: 8px; color: var(--muted); font-size: 11px; }
49
+ .locator-row { margin: 0 14px 14px; }
50
+ .strategy { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; font-weight: 600; }
51
+ .selector { padding: 10px 12px; background: var(--bg); border-radius: 5px; white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; }
52
+ @media (max-width: 420px) { .toolbar, .locators { padding: 12px; } .toolbar-right { width: 100%; } .search-box { width: 100%; } .info { display: block; margin: 4px 0 0 18px; } }
93
53
  </style>
94
54
  </head>
95
55
  <body>
96
- <details>
56
+ <details open>
97
57
  <summary>
98
- <span class="title">📄 Page Source Inspector</span>
58
+ <span class="title">Page Source Inspector</span>
99
59
  <span class="info" id="sourceInfo">Waiting for page source…</span>
100
60
  </summary>
101
61
  <div class="toolbar">
62
+ <input type="search" class="search-box" id="searchBox" placeholder="Find in XML…" aria-label="Find in XML" title="Highlight matching text in the XML">
102
63
  <div class="toolbar-right">
103
- <input type="text" class="search-box" id="searchBox" placeholder="Search…">
104
- <button class="btn btn-secondary" id="copyButton">Copy</button>
105
- <button class="btn btn-secondary" id="formatButton">Format</button>
106
- <button class="btn" id="generateButton">Generate Locators</button>
64
+ <button class="btn btn-secondary" id="formatButton">Format XML</button>
65
+ <button class="btn btn-secondary" id="copyButton">Copy XML</button>
107
66
  </div>
108
67
  </div>
109
- <div class="viewer">
68
+ <div class="viewer" title="Drag the bottom-right corner to resize vertically">
110
69
  <pre class="xml-content empty" id="xmlContent">Waiting for page source…</pre>
111
70
  </div>
71
+ <section class="locators" aria-labelledby="locatorsHeading">
72
+ <div class="section-header">
73
+ <h2 id="locatorsHeading">Locator candidates</h2>
74
+ <button class="btn" id="generateButton">Generate from current page</button>
75
+ </div>
76
+ <p class="hint">Fetches fresh XML from the device and generates candidates for supported element types, including hidden elements. XML search only highlights text above.</p>
77
+ <div id="locatorResults" hidden>
78
+ <p id="locatorStatus" role="status" aria-live="polite"></p>
79
+ <div class="locator-results" id="locatorOutput"></div>
80
+ </div>
81
+ </section>
112
82
  </details>
113
83
  <script>
114
84
  (() => {
@@ -116,6 +86,10 @@ export function createPageSourceInspectorAppUI() {
116
86
  const xmlContent = document.getElementById('xmlContent');
117
87
  const sourceInfo = document.getElementById('sourceInfo');
118
88
  const searchBox = document.getElementById('searchBox');
89
+ const generateButton = document.getElementById('generateButton');
90
+ const locatorResults = document.getElementById('locatorResults');
91
+ const locatorStatus = document.getElementById('locatorStatus');
92
+ const locatorOutput = document.getElementById('locatorOutput');
119
93
  let source = '';
120
94
  let savedFile;
121
95
  let nextRequestId = 1;
@@ -204,10 +178,41 @@ export function createPageSourceInspectorAppUI() {
204
178
  try {
205
179
  const parser = new DOMParser();
206
180
  const documentNode = parser.parseFromString(source, 'text/xml');
207
- if (documentNode.querySelector('parsererror')) {
181
+ if (!documentNode.documentElement || documentNode.getElementsByTagName('parsererror').length) {
208
182
  throw new Error('Invalid XML');
209
183
  }
210
- source = new XMLSerializer().serializeToString(documentNode);
184
+
185
+ function indentElement(element, depth) {
186
+ if (element.getAttribute('xml:space') === 'preserve') return;
187
+ const children = Array.from(element.childNodes);
188
+ const hasMixedContent = children.some((child) =>
189
+ child.nodeType === 4 || (child.nodeType === 3 && (child.nodeValue || '').trim()),
190
+ );
191
+ if (hasMixedContent || !children.some((child) => child.nodeType === 1)) return;
192
+
193
+ for (const child of children) {
194
+ if (child.nodeType === 3) {
195
+ element.removeChild(child);
196
+ continue;
197
+ }
198
+ if (child.nodeType === 1) indentElement(child, depth + 1);
199
+ element.insertBefore(documentNode.createTextNode('\\n' + ' '.repeat(depth + 1)), child);
200
+ }
201
+ element.appendChild(documentNode.createTextNode('\\n' + ' '.repeat(depth)));
202
+ }
203
+
204
+ indentElement(documentNode.documentElement, 0);
205
+ const serializer = new XMLSerializer();
206
+ let formattedSource = Array.from(documentNode.childNodes)
207
+ .filter((node) => node.nodeType !== 3)
208
+ .map((node) => serializer.serializeToString(node))
209
+ .join('\\n');
210
+ const declaration = source.match(/^\\s*(<\\?xml\\s[^?]*\\?>)/);
211
+ if (declaration && !formattedSource.startsWith('<?xml ')) {
212
+ formattedSource = declaration[1] + '\\n' + formattedSource;
213
+ }
214
+
215
+ source = formattedSource;
211
216
  renderSource();
212
217
  } catch {
213
218
  window.alert('Failed to format XML');
@@ -223,11 +228,67 @@ export function createPageSourceInspectorAppUI() {
223
228
  }
224
229
  }
225
230
 
231
+ function renderLocators(elements) {
232
+ locatorOutput.textContent = '';
233
+ elements.forEach((element, index) => {
234
+ const card = document.createElement('details');
235
+ card.className = 'locator-card';
236
+ card.open = index === 0;
237
+ const heading = document.createElement('summary');
238
+ const label = element.text || element.contentDesc || element.resourceId;
239
+ heading.textContent = (index + 1) + '. ' + (label || element.tagName || 'Element');
240
+ if (label && element.tagName) {
241
+ const type = document.createElement('span');
242
+ type.className = 'element-type';
243
+ type.textContent = element.tagName;
244
+ heading.appendChild(type);
245
+ }
246
+ card.appendChild(heading);
247
+ const entries = Object.entries(element.locators || {}).filter(([, value]) => typeof value === 'string');
248
+ entries.forEach(([strategy, selector]) => {
249
+ const row = document.createElement('div');
250
+ row.className = 'locator-row';
251
+ const name = document.createElement('span');
252
+ name.className = 'strategy';
253
+ name.textContent = strategy;
254
+ const code = document.createElement('pre');
255
+ code.className = 'selector';
256
+ code.textContent = selector;
257
+ row.appendChild(name);
258
+ row.appendChild(code);
259
+ card.appendChild(row);
260
+ });
261
+ if (!entries.length) {
262
+ const empty = document.createElement('p');
263
+ empty.className = 'locator-row hint';
264
+ empty.textContent = 'No candidate selectors for this element.';
265
+ card.appendChild(empty);
266
+ }
267
+ locatorOutput.appendChild(card);
268
+ });
269
+ }
270
+
226
271
  async function generateLocators() {
272
+ if (generateButton.disabled) return;
273
+ generateButton.disabled = true;
274
+ locatorResults.hidden = false;
275
+ locatorStatus.textContent = 'Fetching XML and generating candidates…';
276
+ locatorOutput.textContent = '';
227
277
  try {
228
- await sendRequest('tools/call', {name: 'generate_locators', arguments: {}});
229
- } catch {
230
- window.alert('Failed to generate locators');
278
+ const result = await sendRequest('tools/call', {name: 'generate_locators', arguments: {}});
279
+ const text = (result?.content || []).filter((item) => item.type === 'text').map((item) => item.text).join('\\n');
280
+ if (result?.isError) throw new Error(text || 'Tool returned an error');
281
+ const data = JSON.parse(text);
282
+ if (!Array.isArray(data.interactableElements)) throw new Error('No locator data returned');
283
+ const elements = data.interactableElements;
284
+ locatorStatus.textContent = elements.length
285
+ ? 'Candidates generated for ' + elements.length + ' elements from freshly fetched XML.'
286
+ : 'No supported elements found in the fetched XML.';
287
+ renderLocators(elements);
288
+ } catch (error) {
289
+ locatorStatus.textContent = 'Failed to generate locators: ' + error.message;
290
+ } finally {
291
+ generateButton.disabled = false;
231
292
  }
232
293
  }
233
294
 
@@ -262,7 +323,21 @@ export function createPageSourceInspectorAppUI() {
262
323
  appInfo: {name: 'Appium Page Source Inspector', version: '1.0.0'},
263
324
  appCapabilities: {availableDisplayModes: ['inline', 'fullscreen']},
264
325
  })
265
- .then(() => sendNotification('ui/notifications/initialized', {}))
326
+ .then(() => {
327
+ sendNotification('ui/notifications/initialized', {});
328
+ // Let flexible MCP App hosts follow resizing and details expansion.
329
+ if (typeof ResizeObserver !== 'undefined') {
330
+ let previousHeight;
331
+ const observer = new ResizeObserver(() => {
332
+ const height = Math.ceil(document.body.getBoundingClientRect().height);
333
+ if (height !== previousHeight) {
334
+ previousHeight = height;
335
+ sendNotification('ui/notifications/size-changed', {height});
336
+ }
337
+ });
338
+ observer.observe(document.body);
339
+ }
340
+ })
266
341
  .catch(() => {
267
342
  sourceInfo.textContent = 'Unable to initialize inspector';
268
343
  });
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyQN,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoVN,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-mcp",
3
- "version": "1.97.2",
3
+ "version": "1.98.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"
@@ -114,6 +114,7 @@
114
114
  },
115
115
  "optionalDependencies": {
116
116
  "@opentelemetry/api": "^1.9.1",
117
+ "@opentelemetry/exporter-trace-otlp-grpc": "^0.223.0",
117
118
  "@opentelemetry/exporter-trace-otlp-http": "^0.223.0",
118
119
  "@opentelemetry/sdk-node": "^0.223.0",
119
120
  "applesign": "^5.0.0"
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.97.2",
6
+ "version": "1.98.0",
7
7
  "packages": [
8
8
  {
9
9
  "registryType": "npm",
10
10
  "identifier": "appium-mcp",
11
- "version": "1.97.2",
11
+ "version": "1.98.0",
12
12
  "transport": {
13
13
  "type": "stdio"
14
14
  }
@@ -11,6 +11,20 @@ let sdkStarted = false;
11
11
  let shutdownRegistered = false;
12
12
  let sdk: {start(): void; shutdown(): Promise<void>} | undefined;
13
13
 
14
+ /** Resolve trace-specific configuration before the general OTLP setting. */
15
+ export function getTraceExportProtocol(): 'http/json' | 'grpc' {
16
+ const protocol =
17
+ process.env.OTEL_EXPORTER_OTLP_TRACES_PROTOCOL?.trim() ||
18
+ process.env.OTEL_EXPORTER_OTLP_PROTOCOL?.trim() ||
19
+ 'http/json';
20
+ if (protocol !== 'http/json' && protocol !== 'grpc') {
21
+ throw new Error(
22
+ 'Unsupported OTLP trace protocol. Use http/json or grpc in OTEL_EXPORTER_OTLP_TRACES_PROTOCOL or OTEL_EXPORTER_OTLP_PROTOCOL.',
23
+ );
24
+ }
25
+ return protocol;
26
+ }
27
+
14
28
  /**
15
29
  * Initializes the OpenTelemetry SDK if telemetry is enabled and not already started.
16
30
  * This function is idempotent and safe to call multiple times; the SDK will only
@@ -22,9 +36,12 @@ export async function initializeOpenTelemetry(): Promise<void> {
22
36
  return;
23
37
  }
24
38
 
39
+ const protocol = getTraceExportProtocol();
25
40
  const [{NodeSDK}, {OTLPTraceExporter}] = await Promise.all([
26
41
  import('@opentelemetry/sdk-node'),
27
- import('@opentelemetry/exporter-trace-otlp-http'),
42
+ protocol === 'grpc'
43
+ ? import('@opentelemetry/exporter-trace-otlp-grpc')
44
+ : import('@opentelemetry/exporter-trace-otlp-http'),
28
45
  ]);
29
46
 
30
47
  const nodeSdk = new NodeSDK({
@@ -940,7 +940,7 @@ export function createPageSourceInspectorUI(pageSource: string): string {
940
940
  background: #1e1e1e;
941
941
  color: #d4d4d4;
942
942
  padding: 0;
943
- overflow: hidden;
943
+ overflow: auto;
944
944
  }
945
945
  summary {
946
946
  padding: 12px 16px;
@@ -987,7 +987,9 @@ export function createPageSourceInspectorUI(pageSource: string): string {
987
987
  color: #999;
988
988
  }
989
989
  .viewer {
990
- max-height: 320px;
990
+ height: 320px;
991
+ min-height: 160px;
992
+ resize: vertical;
991
993
  overflow: auto;
992
994
  padding: 16px;
993
995
  }
@@ -1036,7 +1038,7 @@ export function createPageSourceInspectorUI(pageSource: string): string {
1036
1038
  <button class="btn" onclick="generateLocators()">Generate Locators</button>
1037
1039
  </div>
1038
1040
  </div>
1039
- <div class="viewer">
1041
+ <div class="viewer" title="Drag the bottom-right corner to resize vertically">
1040
1042
  <pre class="xml-content" id="xmlContent">${escapedSource}</pre>
1041
1043
  </div>
1042
1044
  </details>
@@ -1049,13 +1051,46 @@ export function createPageSourceInspectorUI(pageSource: string): string {
1049
1051
  }
1050
1052
 
1051
1053
  function formatXML() {
1052
- const content = document.getElementById('xmlContent').textContent;
1053
1054
  try {
1054
1055
  const parser = new DOMParser();
1055
- const xmlDoc = parser.parseFromString(content, 'text/xml');
1056
+ const xmlDoc = parser.parseFromString(originalSource, 'text/xml');
1057
+ if (!xmlDoc.documentElement || xmlDoc.getElementsByTagName('parsererror').length) {
1058
+ throw new Error('Invalid XML');
1059
+ }
1060
+
1061
+ function indentElement(element, depth) {
1062
+ // Do not introduce whitespace into mixed content or preserved subtrees.
1063
+ if (element.getAttribute('xml:space') === 'preserve') return;
1064
+ const children = Array.from(element.childNodes);
1065
+ if (children.some(child =>
1066
+ child.nodeType === 4 || (child.nodeType === 3 && child.nodeValue.trim())
1067
+ )) return;
1068
+ if (!children.some(child => child.nodeType === 1)) return;
1069
+
1070
+ for (const child of children) {
1071
+ if (child.nodeType === 3) {
1072
+ element.removeChild(child);
1073
+ continue;
1074
+ }
1075
+ if (child.nodeType === 1) indentElement(child, depth + 1);
1076
+ element.insertBefore(xmlDoc.createTextNode('\\n' + ' '.repeat(depth + 1)), child);
1077
+ }
1078
+ element.appendChild(xmlDoc.createTextNode('\\n' + ' '.repeat(depth)));
1079
+ }
1080
+
1081
+ indentElement(xmlDoc.documentElement, 0);
1056
1082
  const serializer = new XMLSerializer();
1057
- const formatted = serializer.serializeToString(xmlDoc);
1058
- document.getElementById('xmlContent').textContent = formatted;
1083
+ let formatted = Array.from(xmlDoc.childNodes)
1084
+ .filter(node => node.nodeType !== 3)
1085
+ .map(node => serializer.serializeToString(node))
1086
+ .join('\\n');
1087
+ // Browser DOMParser does not retain the XML declaration.
1088
+ const declaration = originalSource.match(/^\\s*(<\\?xml\\s[^?]*\\?>)/);
1089
+ if (declaration && !formatted.startsWith('<?xml ')) {
1090
+ formatted = declaration[1] + '\\n' + formatted;
1091
+ }
1092
+ displayedSource = formatted;
1093
+ renderSource(document.getElementById('searchBox').value);
1059
1094
  } catch (e) {
1060
1095
  alert('Failed to format XML');
1061
1096
  }
@@ -1073,6 +1108,7 @@ export function createPageSourceInspectorUI(pageSource: string): string {
1073
1108
 
1074
1109
  const xmlContent = document.getElementById('xmlContent');
1075
1110
  const originalSource = xmlContent.textContent;
1111
+ let displayedSource = originalSource;
1076
1112
 
1077
1113
  function appendTextWithHighlights(container, text, searchTerm) {
1078
1114
  const searchLower = searchTerm.toLowerCase();
@@ -1104,11 +1140,11 @@ export function createPageSourceInspectorUI(pageSource: string): string {
1104
1140
  function renderSource(searchTerm = '') {
1105
1141
  xmlContent.textContent = '';
1106
1142
  if (!searchTerm) {
1107
- xmlContent.textContent = originalSource;
1143
+ xmlContent.textContent = displayedSource;
1108
1144
  return;
1109
1145
  }
1110
1146
 
1111
- appendTextWithHighlights(xmlContent, originalSource, searchTerm);
1147
+ appendTextWithHighlights(xmlContent, displayedSource, searchTerm);
1112
1148
  }
1113
1149
 
1114
1150
  // Search functionality
@@ -13,102 +13,72 @@ export function createPageSourceInspectorAppUI(): string {
13
13
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
14
14
  <title>Page Source Inspector</title>
15
15
  <style>
16
+ :root { color-scheme: dark; --bg: #17191d; --panel: #202329; --line: #343941; --text: #e5e8ee; --muted: #a3acba; --accent: #91baff; }
16
17
  * { box-sizing: border-box; }
17
- body {
18
- margin: 0;
19
- overflow: hidden;
20
- background: #1e1e1e;
21
- color: #d4d4d4;
22
- font-family: Monaco, Menlo, "Courier New", monospace;
23
- }
24
- summary {
25
- padding: 12px 16px;
26
- background: #2d2d2d;
27
- cursor: pointer;
28
- font-size: 14px;
29
- }
30
- summary .info { margin-left: 8px; }
31
- .toolbar {
32
- display: flex;
33
- flex-wrap: wrap;
34
- align-items: center;
35
- justify-content: space-between;
36
- gap: 12px;
37
- padding: 12px 16px;
38
- border-bottom: 1px solid #3e3e3e;
39
- background: #2d2d2d;
40
- }
41
- .toolbar-right {
42
- flex-wrap: wrap;
43
- display: flex;
44
- align-items: center;
45
- gap: 8px;
46
- }
47
- .title { font-size: 14px; font-weight: 500; }
48
- .info { color: #999; font-size: 12px; }
49
- .btn {
50
- padding: 6px 12px;
51
- border: 0;
52
- border-radius: 4px;
53
- background: #007aff;
54
- color: #fff;
55
- cursor: pointer;
56
- font: 13px -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
57
- }
58
- .btn:hover { background: #0056b3; }
59
- .btn-secondary { background: #444; }
60
- .btn-secondary:hover { background: #555; }
61
- .search-box {
62
- width: 200px;
63
- padding: 6px 12px;
64
- border: 1px solid #555;
65
- border-radius: 4px;
66
- outline: none;
67
- background: #3e3e3e;
68
- color: #d4d4d4;
69
- font-size: 13px;
70
- }
71
- .search-box:focus { border-color: #007aff; }
72
- .viewer {
73
- max-height: 320px;
74
- overflow: auto;
75
- padding: 16px;
76
- }
77
- .xml-content {
78
- margin: 0;
79
- white-space: pre;
80
- color: #d4d4d4;
81
- font-size: 13px;
82
- line-height: 1.6;
83
- }
84
- mark {
85
- border-radius: 2px;
86
- background: #ffd54f;
87
- color: #1e1e1e;
88
- }
89
- .empty {
90
- color: #999;
91
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
92
- }
18
+ [hidden] { display: none !important; }
19
+ body { margin: 0; overflow: auto; background: var(--bg); color: var(--text); font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
20
+ summary { cursor: pointer; padding: 16px 20px; }
21
+ summary::marker { color: var(--muted); }
22
+ .title { font-size: 15px; font-weight: 600; letter-spacing: -.2px; }
23
+ .info { color: var(--muted); font-size: 12px; margin-left: 10px; }
24
+ .toolbar, .section-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
25
+ .toolbar { padding: 12px 20px; border-block: 1px solid var(--line); background: var(--panel); }
26
+ .toolbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
27
+ .btn { padding: 8px 12px; border: 1px solid transparent; border-radius: 7px; background: #a7c7ff; color: #14243d; cursor: pointer; font: inherit; font-weight: 600; }
28
+ .btn:hover { background: #c2d8ff; }
29
+ .btn:disabled { opacity: .55; cursor: wait; }
30
+ .btn-secondary { background: transparent; border-color: #48505d; color: var(--text); }
31
+ .btn-secondary:hover { background: #303641; }
32
+ .btn:focus-visible, summary:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
33
+ .search-box { width: min(240px, 100%); min-width: 0; padding: 8px 12px; border: 1px solid #48505d; border-radius: 7px; background: var(--bg); color: var(--text); font: inherit; }
34
+ .search-box::placeholder { color: var(--muted); }
35
+ .viewer { height: 320px; min-height: 160px; resize: vertical; overflow: auto; padding: 20px; }
36
+ .xml-content, .selector { margin: 0; font: 12px/1.75 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
37
+ .xml-content { white-space: pre; color: #c5d3e7; }
38
+ mark { border-radius: 3px; background: #eac77a; color: #252019; }
39
+ .empty, .hint { color: var(--muted); }
40
+ .empty { font-family: inherit; }
41
+ .hint { margin: 6px 0 0; font-size: 12px; }
42
+ .locators { border-top: 1px solid var(--line); padding: 20px; }
43
+ h2 { margin: 0; font-size: 14px; font-weight: 600; }
44
+ #locatorStatus { margin: 16px 0 10px; color: var(--accent); font-size: 12px; }
45
+ .locator-results { max-height: 480px; overflow: auto; }
46
+ .locator-card { margin: 8px 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); overflow: hidden; }
47
+ .locator-card summary { padding: 12px 14px; overflow-wrap: anywhere; }
48
+ .element-type { margin-left: 8px; color: var(--muted); font-size: 11px; }
49
+ .locator-row { margin: 0 14px 14px; }
50
+ .strategy { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; font-weight: 600; }
51
+ .selector { padding: 10px 12px; background: var(--bg); border-radius: 5px; white-space: pre-wrap; overflow-wrap: anywhere; user-select: all; }
52
+ @media (max-width: 420px) { .toolbar, .locators { padding: 12px; } .toolbar-right { width: 100%; } .search-box { width: 100%; } .info { display: block; margin: 4px 0 0 18px; } }
93
53
  </style>
94
54
  </head>
95
55
  <body>
96
- <details>
56
+ <details open>
97
57
  <summary>
98
- <span class="title">📄 Page Source Inspector</span>
58
+ <span class="title">Page Source Inspector</span>
99
59
  <span class="info" id="sourceInfo">Waiting for page source…</span>
100
60
  </summary>
101
61
  <div class="toolbar">
62
+ <input type="search" class="search-box" id="searchBox" placeholder="Find in XML…" aria-label="Find in XML" title="Highlight matching text in the XML">
102
63
  <div class="toolbar-right">
103
- <input type="text" class="search-box" id="searchBox" placeholder="Search…">
104
- <button class="btn btn-secondary" id="copyButton">Copy</button>
105
- <button class="btn btn-secondary" id="formatButton">Format</button>
106
- <button class="btn" id="generateButton">Generate Locators</button>
64
+ <button class="btn btn-secondary" id="formatButton">Format XML</button>
65
+ <button class="btn btn-secondary" id="copyButton">Copy XML</button>
107
66
  </div>
108
67
  </div>
109
- <div class="viewer">
68
+ <div class="viewer" title="Drag the bottom-right corner to resize vertically">
110
69
  <pre class="xml-content empty" id="xmlContent">Waiting for page source…</pre>
111
70
  </div>
71
+ <section class="locators" aria-labelledby="locatorsHeading">
72
+ <div class="section-header">
73
+ <h2 id="locatorsHeading">Locator candidates</h2>
74
+ <button class="btn" id="generateButton">Generate from current page</button>
75
+ </div>
76
+ <p class="hint">Fetches fresh XML from the device and generates candidates for supported element types, including hidden elements. XML search only highlights text above.</p>
77
+ <div id="locatorResults" hidden>
78
+ <p id="locatorStatus" role="status" aria-live="polite"></p>
79
+ <div class="locator-results" id="locatorOutput"></div>
80
+ </div>
81
+ </section>
112
82
  </details>
113
83
  <script>
114
84
  (() => {
@@ -116,6 +86,10 @@ export function createPageSourceInspectorAppUI(): string {
116
86
  const xmlContent = document.getElementById('xmlContent');
117
87
  const sourceInfo = document.getElementById('sourceInfo');
118
88
  const searchBox = document.getElementById('searchBox');
89
+ const generateButton = document.getElementById('generateButton');
90
+ const locatorResults = document.getElementById('locatorResults');
91
+ const locatorStatus = document.getElementById('locatorStatus');
92
+ const locatorOutput = document.getElementById('locatorOutput');
119
93
  let source = '';
120
94
  let savedFile;
121
95
  let nextRequestId = 1;
@@ -204,10 +178,41 @@ export function createPageSourceInspectorAppUI(): string {
204
178
  try {
205
179
  const parser = new DOMParser();
206
180
  const documentNode = parser.parseFromString(source, 'text/xml');
207
- if (documentNode.querySelector('parsererror')) {
181
+ if (!documentNode.documentElement || documentNode.getElementsByTagName('parsererror').length) {
208
182
  throw new Error('Invalid XML');
209
183
  }
210
- source = new XMLSerializer().serializeToString(documentNode);
184
+
185
+ function indentElement(element, depth) {
186
+ if (element.getAttribute('xml:space') === 'preserve') return;
187
+ const children = Array.from(element.childNodes);
188
+ const hasMixedContent = children.some((child) =>
189
+ child.nodeType === 4 || (child.nodeType === 3 && (child.nodeValue || '').trim()),
190
+ );
191
+ if (hasMixedContent || !children.some((child) => child.nodeType === 1)) return;
192
+
193
+ for (const child of children) {
194
+ if (child.nodeType === 3) {
195
+ element.removeChild(child);
196
+ continue;
197
+ }
198
+ if (child.nodeType === 1) indentElement(child, depth + 1);
199
+ element.insertBefore(documentNode.createTextNode('\\n' + ' '.repeat(depth + 1)), child);
200
+ }
201
+ element.appendChild(documentNode.createTextNode('\\n' + ' '.repeat(depth)));
202
+ }
203
+
204
+ indentElement(documentNode.documentElement, 0);
205
+ const serializer = new XMLSerializer();
206
+ let formattedSource = Array.from(documentNode.childNodes)
207
+ .filter((node) => node.nodeType !== 3)
208
+ .map((node) => serializer.serializeToString(node))
209
+ .join('\\n');
210
+ const declaration = source.match(/^\\s*(<\\?xml\\s[^?]*\\?>)/);
211
+ if (declaration && !formattedSource.startsWith('<?xml ')) {
212
+ formattedSource = declaration[1] + '\\n' + formattedSource;
213
+ }
214
+
215
+ source = formattedSource;
211
216
  renderSource();
212
217
  } catch {
213
218
  window.alert('Failed to format XML');
@@ -223,11 +228,67 @@ export function createPageSourceInspectorAppUI(): string {
223
228
  }
224
229
  }
225
230
 
231
+ function renderLocators(elements) {
232
+ locatorOutput.textContent = '';
233
+ elements.forEach((element, index) => {
234
+ const card = document.createElement('details');
235
+ card.className = 'locator-card';
236
+ card.open = index === 0;
237
+ const heading = document.createElement('summary');
238
+ const label = element.text || element.contentDesc || element.resourceId;
239
+ heading.textContent = (index + 1) + '. ' + (label || element.tagName || 'Element');
240
+ if (label && element.tagName) {
241
+ const type = document.createElement('span');
242
+ type.className = 'element-type';
243
+ type.textContent = element.tagName;
244
+ heading.appendChild(type);
245
+ }
246
+ card.appendChild(heading);
247
+ const entries = Object.entries(element.locators || {}).filter(([, value]) => typeof value === 'string');
248
+ entries.forEach(([strategy, selector]) => {
249
+ const row = document.createElement('div');
250
+ row.className = 'locator-row';
251
+ const name = document.createElement('span');
252
+ name.className = 'strategy';
253
+ name.textContent = strategy;
254
+ const code = document.createElement('pre');
255
+ code.className = 'selector';
256
+ code.textContent = selector;
257
+ row.appendChild(name);
258
+ row.appendChild(code);
259
+ card.appendChild(row);
260
+ });
261
+ if (!entries.length) {
262
+ const empty = document.createElement('p');
263
+ empty.className = 'locator-row hint';
264
+ empty.textContent = 'No candidate selectors for this element.';
265
+ card.appendChild(empty);
266
+ }
267
+ locatorOutput.appendChild(card);
268
+ });
269
+ }
270
+
226
271
  async function generateLocators() {
272
+ if (generateButton.disabled) return;
273
+ generateButton.disabled = true;
274
+ locatorResults.hidden = false;
275
+ locatorStatus.textContent = 'Fetching XML and generating candidates…';
276
+ locatorOutput.textContent = '';
227
277
  try {
228
- await sendRequest('tools/call', {name: 'generate_locators', arguments: {}});
229
- } catch {
230
- window.alert('Failed to generate locators');
278
+ const result = await sendRequest('tools/call', {name: 'generate_locators', arguments: {}});
279
+ const text = (result?.content || []).filter((item) => item.type === 'text').map((item) => item.text).join('\\n');
280
+ if (result?.isError) throw new Error(text || 'Tool returned an error');
281
+ const data = JSON.parse(text);
282
+ if (!Array.isArray(data.interactableElements)) throw new Error('No locator data returned');
283
+ const elements = data.interactableElements;
284
+ locatorStatus.textContent = elements.length
285
+ ? 'Candidates generated for ' + elements.length + ' elements from freshly fetched XML.'
286
+ : 'No supported elements found in the fetched XML.';
287
+ renderLocators(elements);
288
+ } catch (error) {
289
+ locatorStatus.textContent = 'Failed to generate locators: ' + error.message;
290
+ } finally {
291
+ generateButton.disabled = false;
231
292
  }
232
293
  }
233
294
 
@@ -262,7 +323,21 @@ export function createPageSourceInspectorAppUI(): string {
262
323
  appInfo: {name: 'Appium Page Source Inspector', version: '1.0.0'},
263
324
  appCapabilities: {availableDisplayModes: ['inline', 'fullscreen']},
264
325
  })
265
- .then(() => sendNotification('ui/notifications/initialized', {}))
326
+ .then(() => {
327
+ sendNotification('ui/notifications/initialized', {});
328
+ // Let flexible MCP App hosts follow resizing and details expansion.
329
+ if (typeof ResizeObserver !== 'undefined') {
330
+ let previousHeight;
331
+ const observer = new ResizeObserver(() => {
332
+ const height = Math.ceil(document.body.getBoundingClientRect().height);
333
+ if (height !== previousHeight) {
334
+ previousHeight = height;
335
+ sendNotification('ui/notifications/size-changed', {height});
336
+ }
337
+ });
338
+ observer.observe(document.body);
339
+ }
340
+ })
266
341
  .catch(() => {
267
342
  sourceInfo.textContent = 'Unable to initialize inspector';
268
343
  });