appium-mcp 1.92.13 → 1.93.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 +12 -0
- package/README.md +6 -2
- package/dist/ai-finder/vision-finder.d.ts +2 -0
- package/dist/ai-finder/vision-finder.d.ts.map +1 -1
- package/dist/ai-finder/vision-finder.js +27 -9
- package/dist/ai-finder/vision-finder.js.map +1 -1
- package/dist/create-server.js +1 -1
- package/dist/create-server.js.map +1 -1
- package/dist/persistence.d.ts.map +1 -1
- package/dist/persistence.js +17 -4
- package/dist/persistence.js.map +1 -1
- package/dist/plugin.d.ts +4 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +3 -9
- package/dist/plugin.js.map +1 -1
- package/dist/tools/ai/schema.js +1 -1
- package/dist/tools/ai/schema.js.map +1 -1
- package/dist/tools/app-management/app.js +1 -1
- package/dist/tools/app-management/app.js.map +1 -1
- package/dist/tools/app-management/permissions.js +1 -1
- package/dist/tools/app-management/permissions.js.map +1 -1
- package/dist/tools/context/context.js +1 -1
- package/dist/tools/context/context.js.map +1 -1
- package/dist/tools/gestures/drag-and-drop.js +1 -1
- package/dist/tools/gestures/drag-and-drop.js.map +1 -1
- package/dist/tools/gestures/perform-actions.js +1 -1
- package/dist/tools/gestures/perform-actions.js.map +1 -1
- package/dist/tools/gestures/schema.d.ts +1 -1
- package/dist/tools/gestures/schema.d.ts.map +1 -1
- package/dist/tools/gestures/schema.js +48 -41
- package/dist/tools/gestures/schema.js.map +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +3 -26
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/interactions/active-element.js +1 -1
- package/dist/tools/interactions/active-element.js.map +1 -1
- package/dist/tools/interactions/clipboard.js +1 -1
- package/dist/tools/interactions/clipboard.js.map +1 -1
- package/dist/tools/interactions/find.d.ts.map +1 -1
- package/dist/tools/interactions/find.js +23 -24
- package/dist/tools/interactions/find.js.map +1 -1
- package/dist/tools/interactions/get-element-attribute.js +1 -1
- package/dist/tools/interactions/get-element-attribute.js.map +1 -1
- package/dist/tools/interactions/get-page-source.js +1 -1
- package/dist/tools/interactions/get-page-source.js.map +1 -1
- package/dist/tools/interactions/get-text.js +1 -1
- package/dist/tools/interactions/get-text.js.map +1 -1
- package/dist/tools/interactions/handle-alert.js +1 -1
- package/dist/tools/interactions/handle-alert.js.map +1 -1
- package/dist/tools/interactions/keyboard.js +1 -1
- package/dist/tools/interactions/keyboard.js.map +1 -1
- package/dist/tools/interactions/orientation.js +1 -1
- package/dist/tools/interactions/orientation.js.map +1 -1
- package/dist/tools/interactions/press-key.js +1 -1
- package/dist/tools/interactions/press-key.js.map +1 -1
- package/dist/tools/interactions/screen-recording.js +1 -1
- package/dist/tools/interactions/screen-recording.js.map +1 -1
- package/dist/tools/interactions/screenshot.d.ts.map +1 -1
- package/dist/tools/interactions/screenshot.js +5 -13
- package/dist/tools/interactions/screenshot.js.map +1 -1
- package/dist/tools/interactions/set-value.js +1 -1
- package/dist/tools/interactions/set-value.js.map +1 -1
- package/dist/tools/interactions/window-size.js +1 -1
- package/dist/tools/interactions/window-size.js.map +1 -1
- package/dist/tools/ios/prepare-ios-real-device.d.ts.map +1 -1
- package/dist/tools/ios/prepare-ios-real-device.js +4 -7
- package/dist/tools/ios/prepare-ios-real-device.js.map +1 -1
- package/dist/tools/ios/prepare-ios-simulator.d.ts.map +1 -1
- package/dist/tools/ios/prepare-ios-simulator.js +3 -1
- package/dist/tools/ios/prepare-ios-simulator.js.map +1 -1
- package/dist/tools/session/attach-session.js +5 -4
- package/dist/tools/session/attach-session.js.map +1 -1
- package/dist/tools/session/create-session.d.ts +2 -11
- package/dist/tools/session/create-session.d.ts.map +1 -1
- package/dist/tools/session/create-session.js +7 -20
- package/dist/tools/session/create-session.js.map +1 -1
- package/dist/tools/session/device-control.js +1 -1
- package/dist/tools/session/device-control.js.map +1 -1
- package/dist/tools/session/device-info.js +1 -1
- package/dist/tools/session/device-info.js.map +1 -1
- package/dist/tools/session/driver-settings.js +1 -1
- package/dist/tools/session/driver-settings.js.map +1 -1
- package/dist/tools/session/file-transfer.js +1 -1
- package/dist/tools/session/file-transfer.js.map +1 -1
- package/dist/tools/session/geolocation.js +1 -1
- package/dist/tools/session/geolocation.js.map +1 -1
- package/dist/tools/session/select-device.d.ts.map +1 -1
- package/dist/tools/session/select-device.js +7 -24
- package/dist/tools/session/select-device.js.map +1 -1
- package/dist/tools/session/select-session.js +1 -1
- package/dist/tools/session/select-session.js.map +1 -1
- package/dist/tools/session/session.d.ts.map +1 -1
- package/dist/tools/session/session.js +32 -30
- package/dist/tools/session/session.js.map +1 -1
- package/dist/tools/test-generation/generate-tests.d.ts.map +1 -1
- package/dist/tools/test-generation/generate-tests.js +9 -20
- package/dist/tools/test-generation/generate-tests.js.map +1 -1
- package/dist/tools/test-generation/locators.js +1 -1
- package/dist/tools/test-generation/locators.js.map +1 -1
- package/dist/tools/tool-response.d.ts.map +1 -1
- package/dist/tools/tool-response.js +12 -4
- package/dist/tools/tool-response.js.map +1 -1
- package/dist/utils/sensitive.d.ts +7 -0
- package/dist/utils/sensitive.d.ts.map +1 -1
- package/dist/utils/sensitive.js +37 -0
- package/dist/utils/sensitive.js.map +1 -1
- package/dist/utils/url.d.ts +7 -0
- package/dist/utils/url.d.ts.map +1 -1
- package/dist/utils/url.js +23 -0
- package/dist/utils/url.js.map +1 -1
- package/package.json +11 -3
- package/scripts/audit-tool-footprint.mjs +76 -53
- package/server.json +2 -2
- package/src/ai-finder/vision-finder.ts +35 -10
- package/src/create-server.ts +1 -1
- package/src/persistence.ts +18 -4
- package/src/plugin.ts +7 -9
- package/src/tools/ai/schema.ts +1 -1
- package/src/tools/app-management/app.ts +1 -1
- package/src/tools/app-management/permissions.ts +1 -1
- package/src/tools/context/context.ts +1 -1
- package/src/tools/gestures/drag-and-drop.ts +1 -1
- package/src/tools/gestures/perform-actions.ts +1 -1
- package/src/tools/gestures/schema.ts +48 -41
- package/src/tools/index.ts +3 -27
- package/src/tools/interactions/active-element.ts +1 -1
- package/src/tools/interactions/clipboard.ts +1 -1
- package/src/tools/interactions/find.ts +23 -24
- package/src/tools/interactions/get-element-attribute.ts +1 -1
- package/src/tools/interactions/get-page-source.ts +1 -1
- package/src/tools/interactions/get-text.ts +1 -1
- package/src/tools/interactions/handle-alert.ts +1 -1
- package/src/tools/interactions/keyboard.ts +1 -1
- package/src/tools/interactions/orientation.ts +1 -1
- package/src/tools/interactions/press-key.ts +1 -1
- package/src/tools/interactions/screen-recording.ts +1 -1
- package/src/tools/interactions/screenshot.ts +5 -15
- package/src/tools/interactions/set-value.ts +1 -1
- package/src/tools/interactions/window-size.ts +1 -1
- package/src/tools/ios/prepare-ios-real-device.ts +4 -7
- package/src/tools/ios/prepare-ios-simulator.ts +3 -1
- package/src/tools/session/attach-session.ts +5 -4
- package/src/tools/session/create-session.ts +7 -21
- package/src/tools/session/device-control.ts +1 -1
- package/src/tools/session/device-info.ts +1 -1
- package/src/tools/session/driver-settings.ts +1 -1
- package/src/tools/session/file-transfer.ts +1 -1
- package/src/tools/session/geolocation.ts +1 -1
- package/src/tools/session/select-device.ts +8 -28
- package/src/tools/session/select-session.ts +1 -1
- package/src/tools/session/session.ts +32 -30
- package/src/tools/test-generation/generate-tests.ts +9 -20
- package/src/tools/test-generation/locators.ts +1 -1
- package/src/tools/tool-response.ts +14 -4
- package/src/utils/sensitive.ts +42 -0
- package/src/utils/url.ts +26 -0
package/dist/utils/sensitive.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
const SENSITIVE_KEY_PARTS = [
|
|
2
|
+
'access_key',
|
|
2
3
|
'api_key',
|
|
3
4
|
'apikey',
|
|
4
5
|
'authorization',
|
|
5
6
|
'client_secret',
|
|
6
7
|
'clientsecret',
|
|
7
8
|
'credential',
|
|
9
|
+
'passphrase',
|
|
8
10
|
'password',
|
|
11
|
+
'private_key',
|
|
9
12
|
'remote_server_url',
|
|
10
13
|
'remoteserverurl',
|
|
11
14
|
'secret',
|
|
12
15
|
'token',
|
|
13
16
|
];
|
|
17
|
+
const URL_USERINFO_PATTERN = /\b([a-z][a-z0-9+.-]*:\/\/)([^\s/@]+)@/gi;
|
|
14
18
|
/**
|
|
15
19
|
* Determines if a given key is considered sensitive based on whether it includes any of the defined sensitive key parts.
|
|
16
20
|
* The check is case-insensitive and ignores non-alphanumeric characters, so keys like "API-Key", "client secret", or "remote_server_url" would all be correctly identified as sensitive.
|
|
@@ -21,6 +25,39 @@ export function isSensitiveKey(key) {
|
|
|
21
25
|
const normalized = normalizeKey(key);
|
|
22
26
|
return SENSITIVE_KEY_PARTS.some((part) => normalized.includes(normalizeKey(part)));
|
|
23
27
|
}
|
|
28
|
+
/** Removes username/password URL userinfo from text intended for logs or errors. */
|
|
29
|
+
export function redactUrlCredentials(value) {
|
|
30
|
+
return value.replace(URL_USERINFO_PATTERN, '$1[REDACTED]@');
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Produces a JSON-safe copy for logs, redacting sensitive keys, URL userinfo,
|
|
34
|
+
* and values large enough to make logs unsafe or impractical.
|
|
35
|
+
*/
|
|
36
|
+
export function redactForLogging(value) {
|
|
37
|
+
if (value === undefined || value === null) {
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
return JSON.parse(JSON.stringify(value, (key, nestedValue) => {
|
|
42
|
+
if (key && isSensitiveKey(key)) {
|
|
43
|
+
return '[REDACTED]';
|
|
44
|
+
}
|
|
45
|
+
if (typeof nestedValue === 'string') {
|
|
46
|
+
if (nestedValue.length > 2000) {
|
|
47
|
+
return `[string:${nestedValue.length}]`;
|
|
48
|
+
}
|
|
49
|
+
return redactUrlCredentials(nestedValue);
|
|
50
|
+
}
|
|
51
|
+
if (typeof Buffer !== 'undefined' && Buffer.isBuffer(nestedValue)) {
|
|
52
|
+
return `[buffer:${nestedValue.length}]`;
|
|
53
|
+
}
|
|
54
|
+
return nestedValue;
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return '[Unserializable value]';
|
|
59
|
+
}
|
|
60
|
+
}
|
|
24
61
|
function normalizeKey(key) {
|
|
25
62
|
return key.replace(/[^a-zA-Z0-9]/g, '').toLowerCase();
|
|
26
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sensitive.js","sourceRoot":"","sources":["../../src/utils/sensitive.ts"],"names":[],"mappings":"AAAA,MAAM,mBAAmB,GAAG;IAC1B,SAAS;IACT,QAAQ;IACR,eAAe;IACf,eAAe;IACf,cAAc;IACd,YAAY;IACZ,UAAU;IACV,mBAAmB;IACnB,iBAAiB;IACjB,QAAQ;IACR,OAAO;CACR,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,MAAM,UAAU,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IACrC,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACrF,CAAC;AAED,SAAS,YAAY,CAAC,GAAW;IAC/B,OAAO,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AACxD,CAAC"}
|
|
1
|
+
{"version":3,"file":"sensitive.js","sourceRoot":"","sources":["../../src/utils/sensitive.ts"],"names":[],"mappings":"AAAA,MAAM,mBAAmB,GAAG;IAC1B,YAAY;IACZ,SAAS;IACT,QAAQ;IACR,eAAe;IACf,eAAe;IACf,cAAc;IACd,YAAY;IACZ,YAAY;IACZ,UAAU;IACV,aAAa;IACb,mBAAmB;IACnB,iBAAiB;IACjB,QAAQ;IACR,OAAO;CACR,CAAC;AAEF,MAAM,oBAAoB,GAAG,yCAAyC,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,GAA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,YAAY,CAAC,GAAW;IAC/B,OAAO,GAAG,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AACxD,CAAC"}
|
package/dist/utils/url.d.ts
CHANGED
|
@@ -10,6 +10,13 @@ export interface RemoteAttachOptions {
|
|
|
10
10
|
* Defaults to 443 for https and 80 for http when no explicit port is set.
|
|
11
11
|
*/
|
|
12
12
|
export declare function getPortFromUrl(url: URL): number;
|
|
13
|
+
/**
|
|
14
|
+
* Validate a remote Appium server URL and an optional deployment allowlist.
|
|
15
|
+
*
|
|
16
|
+
* The allowlist can only narrow the built-in HTTP(S)-only policy. Queries and
|
|
17
|
+
* fragments are rejected because WebDriver requests use the URL as a base path.
|
|
18
|
+
*/
|
|
19
|
+
export declare function validateRemoteServerUrl(remoteServerUrl: string, regexRule?: string): void;
|
|
13
20
|
/**
|
|
14
21
|
* Attach to an existing remote Appium session given its server URL and id.
|
|
15
22
|
*
|
package/dist/utils/url.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":"AAAA,OAAkB,EAAC,KAAK,MAAM,EAAC,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"url.d.ts","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":"AAAA,OAAkB,EAAC,KAAK,MAAM,EAAC,MAAM,WAAW,CAAC;AAKjD,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACvC;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAE/C;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,eAAe,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAiBzF;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,CAiBzF"}
|
package/dist/utils/url.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import WebDriver from 'webdriver';
|
|
2
|
+
import { redactUrlCredentials } from './sensitive.js';
|
|
2
3
|
import { withQuietWebDriverLogging } from './webdriver-client-options.js';
|
|
3
4
|
/**
|
|
4
5
|
* Resolve the port to use for a given URL.
|
|
@@ -8,6 +9,28 @@ import { withQuietWebDriverLogging } from './webdriver-client-options.js';
|
|
|
8
9
|
export function getPortFromUrl(url) {
|
|
9
10
|
return Number(url.port) || (url.protocol === 'https:' ? 443 : 80);
|
|
10
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Validate a remote Appium server URL and an optional deployment allowlist.
|
|
14
|
+
*
|
|
15
|
+
* The allowlist can only narrow the built-in HTTP(S)-only policy. Queries and
|
|
16
|
+
* fragments are rejected because WebDriver requests use the URL as a base path.
|
|
17
|
+
*/
|
|
18
|
+
export function validateRemoteServerUrl(remoteServerUrl, regexRule) {
|
|
19
|
+
const invalidUrl = () => new Error(`Invalid remoteServerUrl: ${redactUrlCredentials(remoteServerUrl)}.`);
|
|
20
|
+
let parsed;
|
|
21
|
+
try {
|
|
22
|
+
parsed = new URL(remoteServerUrl);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
throw invalidUrl();
|
|
26
|
+
}
|
|
27
|
+
if (!['http:', 'https:'].includes(parsed.protocol) || !parsed.hostname || parsed.search || parsed.hash) {
|
|
28
|
+
throw invalidUrl();
|
|
29
|
+
}
|
|
30
|
+
if (regexRule && !new RegExp(regexRule).test(remoteServerUrl)) {
|
|
31
|
+
throw invalidUrl();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
11
34
|
/**
|
|
12
35
|
* Attach to an existing remote Appium session given its server URL and id.
|
|
13
36
|
*
|
package/d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C9D,MAAM,UAAU,EAAE,CAAC;IACrB,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,OAA4B;IACtE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IAC7C,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC/C,MAAM,IAAI,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IACjC,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACzE,MAAM,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACxE,OAAO,SAAS,CAAC,eAAe,CAC9B,yBAAyB,CAAC;QACxB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,QAAQ;QACR,QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,IAAI;QACJ,IAAI,EAAE,GAAG,CAAC,QAAQ;QAClB,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,EAAC,IAAI,EAAE,GAAG,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KACpC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "appium-mcp",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.93.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"
|
|
@@ -112,10 +112,18 @@
|
|
|
112
112
|
},
|
|
113
113
|
"optionalDependencies": {
|
|
114
114
|
"@opentelemetry/api": "^1.9.1",
|
|
115
|
-
"@opentelemetry/exporter-trace-otlp-http": "^0.
|
|
116
|
-
"@opentelemetry/sdk-node": "^0.
|
|
115
|
+
"@opentelemetry/exporter-trace-otlp-http": "^0.222.0",
|
|
116
|
+
"@opentelemetry/sdk-node": "^0.222.0",
|
|
117
117
|
"applesign": "^5.0.0"
|
|
118
118
|
},
|
|
119
|
+
"overrides": {
|
|
120
|
+
"@puppeteer/browsers": "^3.2.1",
|
|
121
|
+
"applesign": {
|
|
122
|
+
"mocha": "^12.0.0",
|
|
123
|
+
"uuid": "^11.1.1"
|
|
124
|
+
},
|
|
125
|
+
"deepmerge-ts": "^8.0.2"
|
|
126
|
+
},
|
|
119
127
|
"lint-staged": {
|
|
120
128
|
"src/**/*.ts": [
|
|
121
129
|
"eslint src --fix",
|
|
@@ -7,6 +7,7 @@ import {fileURLToPath} from 'node:url';
|
|
|
7
7
|
import {Client} from '@modelcontextprotocol/sdk/client/index.js';
|
|
8
8
|
import {StdioClientTransport} from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
9
9
|
|
|
10
|
+
// Leave room for operational guidance; shorter descriptions must not obscure tool usage.
|
|
10
11
|
const MAX_DISCOVERY_CHARS = 45_000;
|
|
11
12
|
const ESTIMATED_CHARS_PER_TOKEN = 4;
|
|
12
13
|
const LARGEST_TOOL_COUNT = 10;
|
|
@@ -20,65 +21,87 @@ if (!existsSync(serverEntry)) {
|
|
|
20
21
|
process.exit(1);
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
// Only discovery is requested, so the vision configuration never calls an API.
|
|
25
|
+
const configurations = [
|
|
26
|
+
{name: 'headless', env: {NO_UI: 'true'}},
|
|
27
|
+
{name: 'UI enabled', env: {NO_UI: 'false'}},
|
|
28
|
+
{
|
|
29
|
+
name: 'UI and vision enabled',
|
|
30
|
+
env: {
|
|
31
|
+
NO_UI: 'false',
|
|
32
|
+
AI_VISION_ENABLED: 'true',
|
|
33
|
+
AI_VISION_API_BASE_URL: 'https://example.invalid',
|
|
34
|
+
AI_VISION_API_KEY: 'discovery-audit-placeholder',
|
|
35
|
+
},
|
|
32
36
|
},
|
|
33
|
-
|
|
34
|
-
});
|
|
35
|
-
const client = new Client({
|
|
36
|
-
name: 'appium-mcp-tool-footprint-audit',
|
|
37
|
-
version: '1.0.0',
|
|
38
|
-
});
|
|
37
|
+
];
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
await
|
|
42
|
-
|
|
43
|
-
const payloadChars = JSON.stringify(result).length;
|
|
44
|
-
const withoutDescriptionsChars = JSON.stringify(removeDescriptionFields(result)).length;
|
|
45
|
-
const withoutParameterDescriptionsChars = JSON.stringify(removeParameterDescriptions(result)).length;
|
|
46
|
-
const estimatedTokens = Math.ceil(payloadChars / ESTIMATED_CHARS_PER_TOKEN);
|
|
47
|
-
const remainingChars = MAX_DISCOVERY_CHARS - payloadChars;
|
|
48
|
-
const largestTools = result.tools
|
|
49
|
-
.map((tool) => ({
|
|
50
|
-
name: tool.name,
|
|
51
|
-
chars: JSON.stringify(tool).length,
|
|
52
|
-
}))
|
|
53
|
-
.sort((a, b) => b.chars - a.chars || a.name.localeCompare(b.name))
|
|
54
|
-
.slice(0, LARGEST_TOOL_COUNT);
|
|
39
|
+
for (const configuration of configurations) {
|
|
40
|
+
await auditConfiguration(configuration);
|
|
41
|
+
}
|
|
55
42
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
43
|
+
async function auditConfiguration(configuration) {
|
|
44
|
+
const transport = new StdioClientTransport({
|
|
45
|
+
command: process.execPath,
|
|
46
|
+
args: [serverEntry],
|
|
47
|
+
cwd: projectRoot,
|
|
48
|
+
env: {
|
|
49
|
+
AI_VISION_ENABLED: 'false',
|
|
50
|
+
APPIUM_MCP_DOCS_ENABLED: 'false',
|
|
51
|
+
APPIUM_MCP_OTEL_ENABLED: 'false',
|
|
52
|
+
...configuration.env,
|
|
53
|
+
},
|
|
54
|
+
stderr: 'ignore',
|
|
55
|
+
});
|
|
56
|
+
const client = new Client({
|
|
57
|
+
name: 'appium-mcp-tool-footprint-audit',
|
|
58
|
+
version: '1.0.0',
|
|
59
|
+
});
|
|
68
60
|
|
|
69
|
-
|
|
70
|
-
|
|
61
|
+
try {
|
|
62
|
+
await client.connect(transport);
|
|
63
|
+
const result = await client.listTools();
|
|
64
|
+
const payloadChars = JSON.stringify(result).length;
|
|
65
|
+
const withoutDescriptionsChars = JSON.stringify(removeDescriptionFields(result)).length;
|
|
66
|
+
const withoutParameterDescriptionsChars = JSON.stringify(removeParameterDescriptions(result)).length;
|
|
67
|
+
const estimatedTokens = Math.ceil(payloadChars / ESTIMATED_CHARS_PER_TOKEN);
|
|
68
|
+
const remainingChars = MAX_DISCOVERY_CHARS - payloadChars;
|
|
69
|
+
const largestTools = result.tools
|
|
70
|
+
.map((tool) => ({
|
|
71
|
+
name: tool.name,
|
|
72
|
+
chars: JSON.stringify(tool).length,
|
|
73
|
+
}))
|
|
74
|
+
.sort((a, b) => b.chars - a.chars || a.name.localeCompare(b.name))
|
|
75
|
+
.slice(0, LARGEST_TOOL_COUNT);
|
|
76
|
+
|
|
77
|
+
console.log(`MCP tool discovery footprint (${configuration.name})`);
|
|
78
|
+
console.log(`Tools: ${formatNumber(result.tools.length)}`);
|
|
79
|
+
console.log(`Payload: ${formatNumber(payloadChars)} chars (~${formatNumber(estimatedTokens)} tokens)`);
|
|
80
|
+
console.log(`Server instructions (separate): ${formatNumber(client.getInstructions()?.length ?? 0)} chars`);
|
|
81
|
+
console.log(`Description overhead: ${formatNumber(payloadChars - withoutDescriptionsChars)} chars`);
|
|
82
|
+
console.log(
|
|
83
|
+
`Parameter-description overhead: ${formatNumber(payloadChars - withoutParameterDescriptionsChars)} chars`,
|
|
84
|
+
);
|
|
85
|
+
console.log(`Budget: ${formatNumber(MAX_DISCOVERY_CHARS)} chars (${formatSignedNumber(remainingChars)} remaining)`);
|
|
86
|
+
console.log('Largest tools:');
|
|
87
|
+
for (const tool of largestTools) {
|
|
88
|
+
console.log(` ${tool.name}: ${formatNumber(tool.chars)} chars`);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (remainingChars < 0) {
|
|
92
|
+
console.error(`Tool discovery payload exceeds the budget by ${formatNumber(-remainingChars)} chars.`);
|
|
93
|
+
process.exitCode = 1;
|
|
94
|
+
} else {
|
|
95
|
+
console.log('Tool discovery payload is within budget.');
|
|
96
|
+
}
|
|
97
|
+
} catch (error) {
|
|
98
|
+
console.error(
|
|
99
|
+
`Failed to audit MCP tool discovery footprint: ${error instanceof Error ? error.message : String(error)}`,
|
|
100
|
+
);
|
|
71
101
|
process.exitCode = 1;
|
|
72
|
-
}
|
|
73
|
-
|
|
102
|
+
} finally {
|
|
103
|
+
await client.close().catch(() => undefined);
|
|
74
104
|
}
|
|
75
|
-
} catch (error) {
|
|
76
|
-
console.error(
|
|
77
|
-
`Failed to audit MCP tool discovery footprint: ${error instanceof Error ? error.message : String(error)}`,
|
|
78
|
-
);
|
|
79
|
-
process.exitCode = 1;
|
|
80
|
-
} finally {
|
|
81
|
-
await client.close().catch(() => undefined);
|
|
82
105
|
}
|
|
83
106
|
|
|
84
107
|
function removeDescriptionFields(value) {
|
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.
|
|
6
|
+
"version": "1.93.0",
|
|
7
7
|
"packages": [
|
|
8
8
|
{
|
|
9
9
|
"registryType": "npm",
|
|
10
10
|
"identifier": "appium-mcp",
|
|
11
|
-
"version": "1.
|
|
11
|
+
"version": "1.93.0",
|
|
12
12
|
"transport": {
|
|
13
13
|
"type": "stdio"
|
|
14
14
|
}
|
|
@@ -22,6 +22,7 @@ import type {AIVisionConfig, BBox, BBoxCoordinates, AIFindResult} from './types.
|
|
|
22
22
|
export class AIVisionFinder {
|
|
23
23
|
private config: AIVisionConfig;
|
|
24
24
|
private readonly cache: LRUCache<string, AIFindResult>;
|
|
25
|
+
private readonly pendingFinds = new Map<string, Promise<AIFindResult>>();
|
|
25
26
|
private readonly CACHE_TTL_MS = 5 * 60 * 1000; // 5 minutes
|
|
26
27
|
|
|
27
28
|
constructor() {
|
|
@@ -66,18 +67,42 @@ export class AIVisionFinder {
|
|
|
66
67
|
imageWidth: number,
|
|
67
68
|
imageHeight: number,
|
|
68
69
|
): Promise<AIFindResult> {
|
|
70
|
+
log.info(`AI Vision: Finding element with instruction: "${instruction}"`);
|
|
71
|
+
log.debug(`AI Vision: Image dimensions: ${imageWidth}x${imageHeight}`);
|
|
72
|
+
|
|
73
|
+
const cacheKey = this.generateCacheKey(instruction, screenshotBase64);
|
|
74
|
+
const cachedResult = this.getFromCache(cacheKey);
|
|
75
|
+
if (cachedResult) {
|
|
76
|
+
log.info('AI Vision: Using cached result');
|
|
77
|
+
return cachedResult;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Identical concurrent lookups share the API request and annotation work.
|
|
81
|
+
// Include dimensions because they determine the returned coordinates.
|
|
82
|
+
const pendingKey = `${cacheKey}:${imageWidth}x${imageHeight}`;
|
|
83
|
+
const pending = this.pendingFinds.get(pendingKey);
|
|
84
|
+
if (pending) {
|
|
85
|
+
return pending;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const request = this.findUncachedElement(screenshotBase64, instruction, imageWidth, imageHeight, cacheKey);
|
|
89
|
+
this.pendingFinds.set(pendingKey, request);
|
|
69
90
|
try {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
if (cachedResult) {
|
|
77
|
-
log.info('AI Vision: Using cached result');
|
|
78
|
-
return cachedResult;
|
|
79
|
-
}
|
|
91
|
+
return await request;
|
|
92
|
+
} finally {
|
|
93
|
+
// Failures must not remain cached: a later call can retry normally.
|
|
94
|
+
this.pendingFinds.delete(pendingKey);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
80
97
|
|
|
98
|
+
private async findUncachedElement(
|
|
99
|
+
screenshotBase64: string,
|
|
100
|
+
instruction: string,
|
|
101
|
+
imageWidth: number,
|
|
102
|
+
imageHeight: number,
|
|
103
|
+
cacheKey: string,
|
|
104
|
+
): Promise<AIFindResult> {
|
|
105
|
+
try {
|
|
81
106
|
// Step 1: Compress image using @appium/support
|
|
82
107
|
const {base64: compressedBase64, mimeType: compressedMimeType} = await this.compressImage(
|
|
83
108
|
screenshotBase64,
|
package/src/create-server.ts
CHANGED
|
@@ -34,7 +34,7 @@ const SERVER_INSTRUCTIONS = [
|
|
|
34
34
|
'- Call only tools this server actually registers (appium_find_element, appium_gesture, appium_session_management, etc.); do not invent tool names or aliases.',
|
|
35
35
|
'- Prefer stable locators: accessibility id and id before long xpath; use xpath only when nothing else works.',
|
|
36
36
|
'- Use appium_gesture for taps and drags; when something is off-screen, use action=scroll_to_element instead of spamming appium_find_element alone.',
|
|
37
|
-
'- For local
|
|
37
|
+
'- For local install, doctor, or smoke tests, use appium_skills if registered.',
|
|
38
38
|
].join('\n');
|
|
39
39
|
|
|
40
40
|
const FAST_MCP_LOGGER = {
|
package/src/persistence.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {createHash} from 'node:crypto';
|
|
1
|
+
import {createHash, randomBytes} from 'node:crypto';
|
|
2
|
+
import {chmod, lstat, writeFile} from 'node:fs/promises';
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
|
|
4
5
|
import {fs} from '@appium/support';
|
|
@@ -7,6 +8,8 @@ import log from './logger.js';
|
|
|
7
8
|
import type {SessionCapabilities, SessionOwnership} from './session-store.js';
|
|
8
9
|
import {resolveAppiumMcpSessionsDir} from './utils/paths.js';
|
|
9
10
|
|
|
11
|
+
const PRIVATE_FILE_MODE = 0o600;
|
|
12
|
+
|
|
10
13
|
/**
|
|
11
14
|
* On-disk representation of a remote Appium session.
|
|
12
15
|
*
|
|
@@ -76,13 +79,19 @@ export async function readAllPersistedSessions(): Promise<PersistedSession[]> {
|
|
|
76
79
|
for (const name of jsonFiles) {
|
|
77
80
|
const filePath = path.join(dir, name);
|
|
78
81
|
try {
|
|
82
|
+
const fileStats = await lstat(filePath);
|
|
83
|
+
if (!fileStats.isFile()) {
|
|
84
|
+
log.warn(`Skipping persisted session file ${name}: not a regular file`);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
await chmod(filePath, PRIVATE_FILE_MODE);
|
|
79
88
|
const raw = await fs.readFile(filePath, 'utf8');
|
|
80
89
|
const entry = JSON.parse(raw) as PersistedSession;
|
|
81
90
|
const canonicalPath = sessionFilePath(entry.sessionId, dir);
|
|
82
91
|
const canonicalName = path.basename(canonicalPath);
|
|
83
92
|
if (name !== canonicalName) {
|
|
84
93
|
try {
|
|
85
|
-
await
|
|
94
|
+
await writeFile(canonicalPath, raw, {encoding: 'utf8', flag: 'wx', mode: PRIVATE_FILE_MODE});
|
|
86
95
|
} catch (err) {
|
|
87
96
|
if ((err as NodeJS.ErrnoException).code === 'EEXIST') {
|
|
88
97
|
await removeDuplicateSessionFile(filePath, name, entry.sessionId);
|
|
@@ -117,12 +126,17 @@ export async function writePersistedSession(entry: PersistedSession): Promise<vo
|
|
|
117
126
|
return;
|
|
118
127
|
}
|
|
119
128
|
const target = sessionFilePath(entry.sessionId, dir);
|
|
120
|
-
const tmp = `${target}.${process.pid}.tmp`;
|
|
129
|
+
const tmp = `${target}.${process.pid}.${randomBytes(8).toString('hex')}.tmp`;
|
|
121
130
|
try {
|
|
122
131
|
await fs.mkdir(dir, {recursive: true});
|
|
123
132
|
await migrateLegacySessionFile(entry.sessionId, dir);
|
|
124
|
-
await
|
|
133
|
+
await writeFile(tmp, JSON.stringify(entry, null, 2), {
|
|
134
|
+
encoding: 'utf8',
|
|
135
|
+
flag: 'wx',
|
|
136
|
+
mode: PRIVATE_FILE_MODE,
|
|
137
|
+
});
|
|
125
138
|
await fs.rename(tmp, target);
|
|
139
|
+
await chmod(target, PRIVATE_FILE_MODE);
|
|
126
140
|
} catch (err) {
|
|
127
141
|
log.warn(`Failed to persist session ${entry.sessionId}: ${(err as Error).message}`);
|
|
128
142
|
// Best-effort cleanup of the tmp file. Ignore if it does not exist.
|
package/src/plugin.ts
CHANGED
|
@@ -52,6 +52,8 @@ export interface ToolCallContext {
|
|
|
52
52
|
export interface ToolCallResult {
|
|
53
53
|
isError: boolean;
|
|
54
54
|
content: ContentResult['content'];
|
|
55
|
+
structuredContent?: ContentResult['structuredContent'];
|
|
56
|
+
_meta?: ContentResult['_meta'];
|
|
55
57
|
}
|
|
56
58
|
|
|
57
59
|
/**
|
|
@@ -78,6 +80,8 @@ export interface AppiumMcpPlugin {
|
|
|
78
80
|
/**
|
|
79
81
|
* Tool-only hook. Prompts, resources, and resource templates are registered
|
|
80
82
|
* through FastMCP but are not wrapped by plugin call hooks.
|
|
83
|
+
* Return void to preserve the result, or a complete replacement. Spread
|
|
84
|
+
* result when editing content to retain structuredContent and _meta.
|
|
81
85
|
*/
|
|
82
86
|
afterCall?(ctx: ToolCallContext, result: ToolCallResult): Promise<ToolCallResult | void>;
|
|
83
87
|
destroy?(): Promise<void>;
|
|
@@ -358,17 +362,14 @@ export class PluginManager {
|
|
|
358
362
|
}
|
|
359
363
|
const override = await plugin.beforeCall(toolCtx);
|
|
360
364
|
if (override != null) {
|
|
361
|
-
return
|
|
362
|
-
content: override.content,
|
|
363
|
-
isError: override.isError,
|
|
364
|
-
} as ContentResult;
|
|
365
|
+
return override as ContentResult;
|
|
365
366
|
}
|
|
366
367
|
}
|
|
367
368
|
|
|
368
369
|
const rawResult = (await toolDef.execute(args, mcpCtx)) as ContentResult;
|
|
369
370
|
let hookResult: ToolCallResult = {
|
|
371
|
+
...rawResult,
|
|
370
372
|
isError: rawResult.isError ?? false,
|
|
371
|
-
content: rawResult.content as ToolCallResult['content'],
|
|
372
373
|
};
|
|
373
374
|
|
|
374
375
|
for (const plugin of this.pluginMap.values()) {
|
|
@@ -381,10 +382,7 @@ export class PluginManager {
|
|
|
381
382
|
}
|
|
382
383
|
}
|
|
383
384
|
|
|
384
|
-
return
|
|
385
|
-
content: hookResult.content,
|
|
386
|
-
isError: hookResult.isError,
|
|
387
|
-
} as ContentResult;
|
|
385
|
+
return hookResult as ContentResult;
|
|
388
386
|
};
|
|
389
387
|
|
|
390
388
|
return originalAddTool({...toolDef, execute: wrappedExecute});
|
package/src/tools/ai/schema.ts
CHANGED
|
@@ -22,7 +22,7 @@ export const aiSchema = z
|
|
|
22
22
|
`Examples: "yellow search button at bottom", "username input field at top", "settings icon in top-right corner".`,
|
|
23
23
|
),
|
|
24
24
|
|
|
25
|
-
sessionId: z.string().optional().describe('Session ID to
|
|
25
|
+
sessionId: z.string().optional().describe('Session ID; defaults to the active session.'),
|
|
26
26
|
})
|
|
27
27
|
.superRefine((data, ctx) => {
|
|
28
28
|
if (data.action === 'find_element') {
|
|
@@ -54,7 +54,7 @@ const schema = z.object({
|
|
|
54
54
|
.describe(`Background duration; default ${DEFAULT_BACKGROUND_SECONDS}. Use -1 to remain in background.`),
|
|
55
55
|
url: z.string().optional().describe('URL for deep_link (e.g. https://example.com or myapp://path).'),
|
|
56
56
|
waitForLaunch: z.boolean().optional().describe('Android deep_link: wait for the activity to return; default true.'),
|
|
57
|
-
sessionId: z.string().optional().describe('Session ID to
|
|
57
|
+
sessionId: z.string().optional().describe('Session ID; defaults to the active session.'),
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
export default function app(server: FastMCP): void {
|
|
@@ -27,7 +27,7 @@ export default function mobilePermissions(server: FastMCP): void {
|
|
|
27
27
|
.describe(
|
|
28
28
|
'App name resolved to an ID. Android defaults to the app under test; alternative to id for iOS get/update.',
|
|
29
29
|
),
|
|
30
|
-
sessionId: z.string().optional().describe('Session ID to
|
|
30
|
+
sessionId: z.string().optional().describe('Session ID; defaults to the active session.'),
|
|
31
31
|
permissionFilter: z
|
|
32
32
|
.enum(['denied', 'granted', 'requested'])
|
|
33
33
|
.optional()
|
|
@@ -12,7 +12,7 @@ const contextSchema = z.object({
|
|
|
12
12
|
.string()
|
|
13
13
|
.optional()
|
|
14
14
|
.describe('Required when action is switch. Common values: NATIVE_APP or WEBVIEW_<id>/WEBVIEW_<package>.'),
|
|
15
|
-
sessionId: z.string().optional().describe('Session ID to
|
|
15
|
+
sessionId: z.string().optional().describe('Session ID; defaults to the active session.'),
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
export default function context(server: FastMCP): void {
|
|
@@ -64,7 +64,7 @@ const dragAndDropSchema = z.object({
|
|
|
64
64
|
.max(2000)
|
|
65
65
|
.optional()
|
|
66
66
|
.describe('Duration of the long press before dragging in milliseconds. Default 600.'),
|
|
67
|
-
sessionId: z.string().optional().describe('Session ID to
|
|
67
|
+
sessionId: z.string().optional().describe('Session ID; defaults to the active session.'),
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
type DragArgs = z.infer<typeof dragAndDropSchema>;
|
|
@@ -49,7 +49,7 @@ const performActionsSchema = z.object({
|
|
|
49
49
|
`Multiple pointer sources enable multi-touch gestures (e.g. two-finger rotate, three-finger swipe). ` +
|
|
50
50
|
`All sources execute in parallel, synchronized tick-by-tick.`,
|
|
51
51
|
),
|
|
52
|
-
sessionId: z.string().optional().describe('Session ID to
|
|
52
|
+
sessionId: z.string().optional().describe('Session ID; defaults to the active session.'),
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
export default function performActionsTool(server: FastMCP): void {
|