appium-mcp 1.94.0 → 1.94.1

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,13 @@
1
+ ## [1.94.1](https://github.com/appium/appium-mcp/compare/v1.94.0...v1.94.1) (2026-09-18)
2
+
3
+ ### Bug Fixes
4
+
5
+ * **docs:** find globally installed doc package with Homebrew node ([#537](https://github.com/appium/appium-mcp/issues/537)) ([c01d3d9](https://github.com/appium/appium-mcp/commit/c01d3d97f512025cb8203fd34841374165266983))
6
+
7
+ ### Code Refactoring
8
+
9
+ * refactoring cli arguments ([#526](https://github.com/appium/appium-mcp/issues/526)) ([f3fcc0c](https://github.com/appium/appium-mcp/commit/f3fcc0ce3de2a34813c53149fa9e20d7214a60fc))
10
+
1
11
  ## [1.94.0](https://github.com/appium/appium-mcp/compare/v1.93.0...v1.94.0) (2026-09-10)
2
12
 
3
13
  ### Features
package/README.md CHANGED
@@ -148,7 +148,7 @@ This will automatically configure the MCP server for use with Claude Code. Make
148
148
  | Variable | Required | Description |
149
149
  | ----------------------------------------- | -------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
150
150
  | `CAPABILITIES_CONFIG` | Optional | Absolute path to a `capabilities.json` file with per-platform capability presets |
151
- | `SCREENSHOTS_DIR` | Optional | Directory where screenshots and screen recordings are saved. Defaults to the current working directory |
151
+ | `SCREENSHOTS_DIR` | Optional | Directory where screenshots and screen recordings are saved. Defaults to the system temp directory (`os.tmpdir()`) |
152
152
  | `NO_UI` | Optional | Set to `true` or `1` to disable HTML UI components — faster responses, fewer tokens. See [NO_UI Mode](#no_ui-mode) |
153
153
  | `APPIUM_MCP_APPS_ENABLED` | Optional | MCP Apps static UI mode. Enabled by default. Set to `false` or `0` to force the embedded UI compatibility fallback. See [MCP Apps Mode](#mcp-apps-mode) |
154
154
  | `APPIUM_MCP_ON_CLIENT_DISCONNECT` | Optional | Session cleanup when the MCP client disconnects: `delete_all` (default) deletes **MCP-owned** Appium sessions (`safeDeleteAllSessions`); `skip` keeps those sessions across disconnects (e.g. HTTP/stream clients that reconnect). Attached/remote sessions are not removed by this path. See [MCP disconnect behavior](#mcp-disconnect-behavior). |
@@ -266,7 +266,7 @@ Tool calls are logged with argument **redaction** implemented via **`JSON.string
266
266
 
267
267
  ### Screenshots
268
268
 
269
- Set the `SCREENSHOTS_DIR` environment variable to specify where screenshots are saved. If not set, screenshots are saved to the current working directory. Supports both absolute and relative paths (relative paths are resolved from the current working directory). The directory is created automatically if it doesn't exist.
269
+ Set the `SCREENSHOTS_DIR` environment variable to specify where screenshots are saved. If not set, screenshots are saved to the system temp directory (`os.tmpdir()`). Supports both absolute and relative paths (relative paths are resolved from the current working directory). The directory is created automatically if it doesn't exist.
270
270
 
271
271
  ### Screen Recording
272
272
 
@@ -1,2 +1,2 @@
1
- export declare function runCli(args?: string[]): Promise<void>;
1
+ export declare function runCli(args?: readonly string[]): Promise<void>;
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAGA,wBAAsB,MAAM,CAAC,IAAI,GAAE,MAAM,EAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAYlF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAMA,wBAAsB,MAAM,CAAC,IAAI,GAAE,SAAS,MAAM,EAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAa3F"}
package/dist/cli/index.js CHANGED
@@ -1,51 +1,50 @@
1
1
  import log, { configureStdioTransportLogging } from '../logger.js';
2
+ import { DEFAULT_HTTP_STREAM_OPTIONS, TRANSPORT_TYPES } from '../transport.js';
3
+ import { CLI_COMMANDS, CLI_OPTIONS, CLI_VALUE_PREFIXES } from './options.js';
2
4
  import { loadCliPlugins } from './plugins.js';
3
5
  export async function runCli(args = process.argv.slice(2)) {
4
6
  const command = args[0];
5
- if (command === '--help' || command === '-h' || command === 'help') {
7
+ if (command === CLI_OPTIONS.help || command === CLI_OPTIONS.shortHelp || command === CLI_COMMANDS.help) {
6
8
  printHelp();
7
9
  return;
8
10
  }
9
- if (!args.includes('--httpStream')) {
11
+ const useHttpStream = args.includes(CLI_OPTIONS.httpStream);
12
+ if (!useHttpStream) {
10
13
  configureStdioTransportLogging();
11
14
  }
12
- await startServer(args);
15
+ await startServer(args, useHttpStream);
13
16
  }
14
17
  function printHelp() {
15
18
  log.info(`Usage: appium-mcp [command] [options]
16
19
 
17
20
  Options:
18
- --httpStream Start with httpStream transport
19
- --port=<port> Port for httpStream transport (default: 8080)
20
- --plugin=<module> Load a plugin from a local path or installed package (repeatable)
21
- --help Show this help message`);
21
+ ${CLI_OPTIONS.httpStream} Start with httpStream transport
22
+ ${CLI_VALUE_PREFIXES.port}<port> Port for httpStream transport (default: ${DEFAULT_HTTP_STREAM_OPTIONS.port})
23
+ ${CLI_VALUE_PREFIXES.plugin}<module> Load a plugin from a local path or installed package (repeatable)
24
+ ${CLI_OPTIONS.help} Show this help message`);
22
25
  }
23
- async function startServer(args) {
24
- const useHttpStream = args.includes('--httpStream');
25
- const port = args.find((arg) => arg.startsWith('--port='))?.split('=')[1] || '8080';
26
+ async function startServer(args, useHttpStream) {
27
+ const port = args.find((arg) => arg.startsWith(CLI_VALUE_PREFIXES.port))?.split('=')[1] ||
28
+ String(DEFAULT_HTTP_STREAM_OPTIONS.port);
26
29
  log.info('Starting MCP Appium MCP Server...');
27
30
  try {
28
31
  const plugins = await loadCliPlugins(args);
29
32
  const { default: createDefaultServer } = await import('../server.js');
30
33
  const server = await createDefaultServer(plugins);
34
+ const startOptions = useHttpStream
35
+ ? {
36
+ transportType: TRANSPORT_TYPES.httpStream,
37
+ httpStream: { ...DEFAULT_HTTP_STREAM_OPTIONS, port: parseInt(port, 10) },
38
+ }
39
+ : { transportType: TRANSPORT_TYPES.stdio };
40
+ await server.start(startOptions);
31
41
  if (useHttpStream) {
32
- await server.start({
33
- transportType: 'httpStream',
34
- httpStream: {
35
- endpoint: '/sse',
36
- port: parseInt(port, 10),
37
- },
38
- });
39
- log.info(`Server started with httpStream transport on http://localhost:${port}/sse`);
40
- log.info('Waiting for client connections...');
42
+ log.info(`Server started with httpStream transport on http://localhost:${port}${DEFAULT_HTTP_STREAM_OPTIONS.endpoint}`);
41
43
  }
42
44
  else {
43
- await server.start({
44
- transportType: 'stdio',
45
- });
46
45
  log.info('Server started with stdio transport');
47
- log.info('Waiting for client connections...');
48
46
  }
47
+ log.info('Waiting for client connections...');
49
48
  }
50
49
  catch (error) {
51
50
  log.error('Error starting server:', error);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,EAAE,EAAC,8BAA8B,EAAC,MAAM,cAAc,CAAC;AACjE,OAAO,EAAC,cAAc,EAAC,MAAM,cAAc,CAAC;AAE5C,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAiB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACjE,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACxB,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QACnE,SAAS,EAAE,CAAC;QACZ,OAAO;IACT,CAAC;IAED,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;QACnC,8BAA8B,EAAE,CAAC;IACnC,CAAC;IAED,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,SAAS;IAChB,GAAG,CAAC,IAAI,CAAC;;;;;;uCAM4B,CAAC,CAAC;AACzC,CAAC;AAED,KAAK,UAAU,WAAW,CAAC,IAA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+ readonly help: "help";
3
+ };
4
+ export declare const CLI_OPTIONS: {
5
+ readonly help: "--help";
6
+ readonly shortHelp: "-h";
7
+ readonly httpStream: "--httpStream";
8
+ readonly port: "--port";
9
+ readonly plugin: "--plugin";
10
+ };
11
+ export declare const CLI_VALUE_PREFIXES: {
12
+ readonly port: "--port=";
13
+ readonly plugin: "--plugin=";
14
+ };
15
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/cli/options.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;;CAEf,CAAC;AAEX,eAAO,MAAM,WAAW;;;;;;CAMd,CAAC;AAEX,eAAO,MAAM,kBAAkB;;;CAGrB,CAAC"}
@@ -0,0 +1,15 @@
1
+ export const CLI_COMMANDS = {
2
+ help: 'help',
3
+ };
4
+ export const CLI_OPTIONS = {
5
+ help: '--help',
6
+ shortHelp: '-h',
7
+ httpStream: '--httpStream',
8
+ port: '--port',
9
+ plugin: '--plugin',
10
+ };
11
+ export const CLI_VALUE_PREFIXES = {
12
+ port: `${CLI_OPTIONS.port}=`,
13
+ plugin: `${CLI_OPTIONS.plugin}=`,
14
+ };
15
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/cli/options.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,MAAM;CACJ,CAAC;AAEX,MAAM,CAAC,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,QAAQ;IACd,SAAS,EAAE,IAAI;IACf,UAAU,EAAE,cAAc;IAC1B,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE,UAAU;CACV,CAAC;AAEX,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,IAAI,EAAE,GAAG,WAAW,CAAC,IAAI,GAAG;IAC5B,MAAM,EAAE,GAAG,WAAW,CAAC,MAAM,GAAG;CACxB,CAAC"}
@@ -1,4 +1,4 @@
1
1
  import type { AppiumMcpPlugin } from '../core.js';
2
2
  /** Load explicitly requested plugins in command-line order, relative to the caller. */
3
- export declare function loadCliPlugins(args: string[], cwd?: string): Promise<AppiumMcpPlugin[]>;
3
+ export declare function loadCliPlugins(args: readonly string[], cwd?: string): Promise<AppiumMcpPlugin[]>;
4
4
  //# sourceMappingURL=plugins.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../src/cli/plugins.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,YAAY,CAAC;AAEhD,uFAAuF;AACvF,wBAAsB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,SAAgB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAuCpG"}
1
+ {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../src/cli/plugins.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,YAAY,CAAC;AAmBhD,uFAAuF;AACvF,wBAAsB,cAAc,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,SAAgB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAS7G"}
@@ -1,59 +1,88 @@
1
1
  import { createRequire } from 'node:module';
2
2
  import { isAbsolute, resolve as resolvePath } from 'node:path';
3
3
  import { pathToFileURL } from 'node:url';
4
+ import { CLI_OPTIONS, CLI_VALUE_PREFIXES } from './options.js';
5
+ // Require a runtime check for every field in the plugin contract.
6
+ const PLUGIN_FIELD_TYPES = {
7
+ name: 'string',
8
+ version: 'string',
9
+ initialize: 'function',
10
+ register: 'function',
11
+ beforeCall: 'function',
12
+ afterCall: 'function',
13
+ destroy: 'function',
14
+ };
4
15
  /** Load explicitly requested plugins in command-line order, relative to the caller. */
5
16
  export async function loadCliPlugins(args, cwd = process.cwd()) {
17
+ const specifiers = parsePluginSpecifiers(args);
18
+ const requireFromCwd = createRequire(resolvePath(cwd, 'package.json'));
19
+ const plugins = [];
20
+ for (const specifier of specifiers) {
21
+ // Imports and constructors can have side effects, so preserve flag order.
22
+ plugins.push(await loadPlugin(specifier, cwd, requireFromCwd.resolve));
23
+ }
24
+ return plugins;
25
+ }
26
+ function parsePluginSpecifiers(args) {
6
27
  const specifiers = [];
7
28
  for (let index = 0; index < args.length; index++) {
8
29
  const arg = args[index];
9
- if (arg !== '--plugin' && !arg.startsWith('--plugin=')) {
30
+ if (arg !== CLI_OPTIONS.plugin && !arg.startsWith(CLI_VALUE_PREFIXES.plugin)) {
10
31
  continue;
11
32
  }
12
- const specifier = arg === '--plugin' ? args[++index] : arg.slice('--plugin='.length);
33
+ const specifier = arg === CLI_OPTIONS.plugin ? args[++index] : arg.slice(CLI_VALUE_PREFIXES.plugin.length);
13
34
  if (!specifier?.trim() || specifier.startsWith('--')) {
14
- throw new Error('--plugin requires a module path or an installed package name.');
35
+ throw new Error(`${CLI_OPTIONS.plugin} requires a module path or an installed package name.`);
15
36
  }
16
37
  specifiers.push(specifier);
17
38
  }
18
- const plugins = [];
19
- const requireFromCwd = createRequire(resolvePath(cwd, 'package.json'));
20
- for (const specifier of specifiers) {
21
- try {
22
- const moduleSpecifier = isAbsolute(specifier) || specifier.startsWith('.')
23
- ? resolvePath(cwd, specifier)
24
- : URL.canParse(specifier)
25
- ? new URL(specifier).href
26
- : requireFromCwd.resolve(specifier);
27
- const moduleURL = isAbsolute(moduleSpecifier) ? pathToFileURL(moduleSpecifier).href : moduleSpecifier;
28
- if (!moduleURL.startsWith('file:')) {
29
- throw new Error('Only local files and installed packages are supported.');
30
- }
31
- const module = (await import(moduleURL));
32
- const exported = module.default;
33
- const plugin = typeof exported === 'function' ? new exported() : exported;
34
- assertPlugin(plugin);
35
- plugins.push(plugin);
36
- }
37
- catch (error) {
38
- const message = error instanceof Error ? error.message : String(error);
39
- throw new Error(`Failed to load plugin "${specifier}": ${message}`, { cause: error });
40
- }
39
+ return specifiers;
40
+ }
41
+ function resolvePluginUrl(specifier, cwd, resolvePackage) {
42
+ let moduleSpecifier;
43
+ if (isAbsolute(specifier) || specifier.startsWith('.')) {
44
+ moduleSpecifier = resolvePath(cwd, specifier);
45
+ }
46
+ else if (URL.canParse(specifier)) {
47
+ moduleSpecifier = new URL(specifier).href;
48
+ }
49
+ else {
50
+ moduleSpecifier = resolvePackage(specifier);
51
+ }
52
+ const moduleURL = isAbsolute(moduleSpecifier) ? pathToFileURL(moduleSpecifier).href : moduleSpecifier;
53
+ if (!moduleURL.startsWith('file:')) {
54
+ throw new Error('Only local files and installed packages are supported.');
55
+ }
56
+ return moduleURL;
57
+ }
58
+ async function loadPlugin(specifier, cwd, resolvePackage) {
59
+ try {
60
+ const moduleURL = resolvePluginUrl(specifier, cwd, resolvePackage);
61
+ const module = (await import(moduleURL));
62
+ const exported = module.default;
63
+ const plugin = typeof exported === 'function' ? new exported() : exported;
64
+ assertPlugin(plugin);
65
+ return plugin;
66
+ }
67
+ catch (error) {
68
+ const message = error instanceof Error ? error.message : String(error);
69
+ throw new Error(`Failed to load plugin "${specifier}": ${message}`, { cause: error });
41
70
  }
42
- return plugins;
43
71
  }
44
72
  function assertPlugin(plugin) {
45
73
  if (typeof plugin !== 'object' || plugin === null) {
46
74
  throw new Error('The default export must be an AppiumMcpPlugin object or a class with a no-argument constructor.');
47
75
  }
48
76
  const candidate = plugin;
49
- for (const field of ['name', 'version']) {
50
- if (typeof candidate[field] !== 'string' || !candidate[field].trim()) {
51
- throw new Error(`The plugin must have a non-empty string "${field}".`);
77
+ for (const [field, expectedType] of Object.entries(PLUGIN_FIELD_TYPES)) {
78
+ const value = candidate[field];
79
+ if (expectedType === 'string') {
80
+ if (typeof value !== 'string' || !value.trim()) {
81
+ throw new Error(`The plugin must have a non-empty string "${field}".`);
82
+ }
52
83
  }
53
- }
54
- for (const hook of ['initialize', 'register', 'beforeCall', 'afterCall', 'destroy']) {
55
- if (candidate[hook] !== undefined && typeof candidate[hook] !== 'function') {
56
- throw new Error(`Plugin "${candidate.name}" has an invalid "${hook}" hook; expected a function.`);
84
+ else if (value !== undefined && typeof value !== 'function') {
85
+ throw new Error(`Plugin "${candidate.name}" has an invalid "${field}" hook; expected a function.`);
57
86
  }
58
87
  }
59
88
  }
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../src/cli/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAC,UAAU,EAAE,OAAO,IAAI,WAAW,EAAC,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AAIvC,uFAAuF;AACvF,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAc,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE;IACtE,MAAM,UAAU,GAAa,EAAE,CAAC;IAChC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACjD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QACxB,IAAI,GAAG,KAAK,UAAU,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE,CAAC;YACvD,SAAS;QACX,CAAC;QACD,MAAM,SAAS,GAAG,GAAG,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QACrF,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACrD,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;QACnF,CAAC;QACD,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7B,C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,KAAK,CAAC,4CAA4C,KAAK,IAAI,CAAC,CAAC;YACzE,CAAC;QACH,CAAC;aAAM,IAAI,KAAK,KAAK,SAAS,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;YAC9D,MAAM,IAAI,KAAK,CAAC,WAAW,SAAS,CAAC,IAAI,qBAAqB,KAAK,8BAA8B,CAAC,CAAC;QACrG,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"create-server.d.ts","sourceRoot":"","sources":["../src/create-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAKhC,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EAAgB,KAAK,eAAe,EAAC,MAAM,aAAa,CAAC;AA0BhE,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAE5B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,aAAa,CAAC,EAAE,GAAG,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC;IAEhD;;OAEG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B;AAQD;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,GAAE,4BAAiC,GAAG,OAAO,CAAC,OAAO,CAAC,CAuKxG"}
1
+ {"version":3,"file":"create-server.d.ts","sourceRoot":"","sources":["../src/create-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAKhC,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,aAAa,CAAC;AACjD,OAAO,EAAgB,KAAK,eAAe,EAAC,MAAM,aAAa,CAAC;AA2BhE,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,OAAO,CAAC,EAAE,eAAe,EAAE,CAAC;IAE5B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,aAAa,CAAC,EAAE,GAAG,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC;IAEhD;;OAEG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAEhC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;CAC1B;AAQD;;;;;;;;;GASG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,GAAE,4BAAiC,GAAG,OAAO,CAAC,OAAO,CAAC,CAuKxG"}
@@ -22,6 +22,7 @@ import { safeDeleteAllSessions, listSessions } from './session-store.js';
22
22
  import { initializeOpenTelemetry } from './telemetry/init.js';
23
23
  import { installTelemetryWrappers } from './telemetry/wrapOperations.js';
24
24
  import registerTools from './tools/index.js';
25
+ import { TRANSPORT_TYPES } from './transport.js';
25
26
  const SERVER_VERSION = pkg.version;
26
27
  const SERVER_INSTRUCTIONS = [
27
28
  'Appium mobile automation through MCP. Defaults that avoid broken flows:',
@@ -193,7 +194,7 @@ export async function createAppiumMcpServer(options = {}) {
193
194
  function wrapStartForStdioLogging(server) {
194
195
  const originalStart = server.start.bind(server);
195
196
  server.start = (async (startOptions) => {
196
- if ((startOptions?.transportType ?? 'stdio') === 'stdio') {
197
+ if ((startOptions?.transportType ?? TRANSPORT_TYPES.stdio) === TRANSPORT_TYPES.stdio) {
197
198
  configureStdioTransportLogging();
198
199
  }
199
200
  return originalStart(startOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"create-server.js","sourceRoot":"","sources":["../src/create-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAEhC,OAAO,GAAG,MAAM,iBAAiB,CAAC,OAAM,IAAI,EAAE,MAAM,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C,CAAC,CAAC;IACnG,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC"}
@@ -109,9 +109,15 @@ async function resolveGlobalEntryUrl() {
109
109
  const execDir = path.dirname(process.execPath);
110
110
  // npm global roots by platform (each entry is a resolution starting point,
111
111
  // so `<entry>/node_modules` is checked):
112
- // - POSIX (nvm, system, Homebrew): <prefix>/lib/node_modules
112
+ // - POSIX (nvm, system): <prefix>/lib/node_modules
113
113
  // - Windows (node.exe in <prefix>): <prefix>/node_modules
114
114
  const paths = [path.join(execDir, '..', 'lib'), execDir];
115
+ // Homebrew runs node from <prefix>/Cellar/node/<version>/bin but installs global
116
+ // packages into <prefix>/lib/node_modules.
117
+ const cellarIndex = execDir.lastIndexOf(`${path.sep}Cellar${path.sep}`);
118
+ if (cellarIndex !== -1) {
119
+ paths.push(path.join(execDir.slice(0, cellarIndex), 'lib'));
120
+ }
115
121
  const pkgJsonPath = require.resolve(`${PACKAGE_NAME}/package.json`, {
116
122
  paths,
117
123
  });
@@ -1 +1 @@
1
- {"version":3,"file":"documentation.js","sourceRoot":"","sources":["../src/documentation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAC1C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AAEvC,OAAO,EAAC,EAAE,EAAC,MAAM,iBAAiB,CAAC;AAGnC,OAAO,GAAG,MAAM,aAAa,CAAC;AAC9B,OAAO,EAAC,gBAAgB,EAAC,MAAM,gBAAgB,CAAC;AAEhD,MAAM,YAAY,GAAG,yBAAyB,CAAC;AAC/C,MAAM,YAAY,GAAG,2BAA2B,CAAC;AAMjD,iEAAiE;AACjE,MAAM,UAAU,sBAAsB;IACpC,OAAO,gBAAgB,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC;AACrD,CAAC;AAED;;;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CHANGED
@@ -1,3 +1,4 @@
1
+ import type { FastMCP } from 'fastmcp';
1
2
  import type { AppiumMcpPlugin } from './core.js';
2
- export default function createDefaultServer(additionalPlugins?: AppiumMcpPlugin[]): Promise<import("fastmcp").FastMCP<import("fastmcp").FastMCPSessionAuth>>;
3
+ export default function createDefaultServer(additionalPlugins?: readonly AppiumMcpPlugin[]): Promise<FastMCP>;
3
4
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,WAAW,CAAC;AAI/C,wBAA8B,mBAAmB,CAAC,iBAAiB,GAAE,eAAe,EAAO,4EAc1F"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAErC,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,WAAW,CAAC;AAI/C,wBAA8B,mBAAmB,CAC/C,iBAAiB,GAAE,SAAS,eAAe,EAAO,GACjD,OAAO,CAAC,OAAO,CAAC,CAclB"}
package/dist/server.js CHANGED
@@ -1,16 +1,16 @@
1
1
  import { createAppiumMcpServer } from './create-server.js';
2
2
  import { isDocumentationEnabled, loadDocumentationPlugin } from './documentation.js';
3
3
  export default async function createDefaultServer(additionalPlugins = []) {
4
- const plugins = [];
4
+ const plugins = [...additionalPlugins];
5
5
  // Documentation tools (RAG docs query + skills) are opt-in. They live in a
6
6
  // separate package only installed when the user sets
7
7
  // APPIUM_MCP_DOCS_ENABLED. See ./documentation.ts for the full contract.
8
8
  if (isDocumentationEnabled()) {
9
9
  const documentationPlugin = await loadDocumentationPlugin();
10
10
  if (documentationPlugin) {
11
- plugins.push(documentationPlugin);
11
+ plugins.unshift(documentationPlugin);
12
12
  }
13
13
  }
14
- return await createAppiumMcpServer({ plugins: [...plugins, ...additionalPlugins] });
14
+ return createAppiumMcpServer({ plugins });
15
15
  }
16
16
  //# sourceMappingURL=server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,qBAAqB,EAAC,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAC,sBAAsB,EAAE,uBAAuB,EAAC,MAAM,oBAAoB,CAAC;AAEnF,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,mBAAmB,CAAC,oBAAuC,EAAE;IACzF,MAAM,OAAO,GAAsB,EAAE,CAAC;IAEtC,2EAA2E;IAC3E,qDAAqD;IACrD,yEAAyE;IACzE,IAAI,sBAAsB,EAAE,EAAE,CAAC;QAC7B,MAAM,mBAAmB,GAAG,MAAM,uBAAuB,EAAE,CAAC;QAC5D,IAAI,mBAAmB,EAAE,CAAC;YACxB,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IAED,OAAO,MAAM,qBAAqB,CAAC,EAAC,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,GAAG,iBAAiB,CAAC,EAAC,CAAC,CAAC;AACpF,CAAC"}
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,qBAAqB,EAAC,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAC,sBAAsB,EAAE,uBAAuB,EAAC,MAAM,oBAAoB,CAAC;AAEnF,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,mBAAmB,CAC/C,oBAAgD,EAAE;IAElD,MAAM,OAAO,GAAG,CAAC,GAAG,iBAAiB,CAAC,CAAC;IAEvC,2EAA2E;IAC3E,qDAAqD;IACrD,yEAAyE;IACzE,IAAI,sBAAsB,EAAE,EAAE,CAAC;QAC7B,MAAM,mBAAmB,GAAG,MAAM,uBAAuB,EAAE,CAAC;QAC5D,IAAI,mBAAmB,EAAE,CAAC;YACxB,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;QACvC,CAAC;IACH,CAAC;IAED,OAAO,qBAAqB,CAAC,EAAC,OAAO,EAAC,CAAC,CAAC;AAC1C,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { FastMCP } from 'fastmcp';
2
+ export type ServerStartOptions = NonNullable<Parameters<FastMCP['start']>[0]>;
3
+ export declare const TRANSPORT_TYPES: {
4
+ readonly stdio: "stdio";
5
+ readonly httpStream: "httpStream";
6
+ };
7
+ export declare const DEFAULT_HTTP_STREAM_OPTIONS: {
8
+ readonly endpoint: "/sse";
9
+ readonly port: 8080;
10
+ };
11
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,OAAO,EAAC,MAAM,SAAS,CAAC;AAErC,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE9E,eAAO,MAAM,eAAe;;;CAG4C,CAAC;AAEzE,eAAO,MAAM,2BAA2B;;;CAG0B,CAAC"}
@@ -0,0 +1,9 @@
1
+ export const TRANSPORT_TYPES = {
2
+ stdio: 'stdio',
3
+ httpStream: 'httpStream',
4
+ };
5
+ export const DEFAULT_HTTP_STREAM_OPTIONS = {
6
+ endpoint: '/sse',
7
+ port: 8080,
8
+ };
9
+ //# sourceMappingURL=transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,YAAY;CAC8C,CAAC;AAEzE,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,QAAQ,EAAE,MAAM;IAChB,IAAI,EAAE,IAAI;CACsD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "appium-mcp",
3
- "version": "1.94.0",
3
+ "version": "1.94.1",
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"
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.94.0",
6
+ "version": "1.94.1",
7
7
  "packages": [
8
8
  {
9
9
  "registryType": "npm",
10
10
  "identifier": "appium-mcp",
11
- "version": "1.94.0",
11
+ "version": "1.94.1",
12
12
  "transport": {
13
13
  "type": "stdio"
14
14
  }
package/src/cli/index.ts CHANGED
@@ -1,33 +1,38 @@
1
1
  import log, {configureStdioTransportLogging} from '../logger.js';
2
+ import {DEFAULT_HTTP_STREAM_OPTIONS, TRANSPORT_TYPES} from '../transport.js';
3
+ import type {ServerStartOptions} from '../transport.js';
4
+ import {CLI_COMMANDS, CLI_OPTIONS, CLI_VALUE_PREFIXES} from './options.js';
2
5
  import {loadCliPlugins} from './plugins.js';
3
6
 
4
- export async function runCli(args: string[] = process.argv.slice(2)): Promise<void> {
7
+ export async function runCli(args: readonly string[] = process.argv.slice(2)): Promise<void> {
5
8
  const command = args[0];
6
- if (command === '--help' || command === '-h' || command === 'help') {
9
+ if (command === CLI_OPTIONS.help || command === CLI_OPTIONS.shortHelp || command === CLI_COMMANDS.help) {
7
10
  printHelp();
8
11
  return;
9
12
  }
10
13
 
11
- if (!args.includes('--httpStream')) {
14
+ const useHttpStream = args.includes(CLI_OPTIONS.httpStream);
15
+ if (!useHttpStream) {
12
16
  configureStdioTransportLogging();
13
17
  }
14
18
 
15
- await startServer(args);
19
+ await startServer(args, useHttpStream);
16
20
  }
17
21
 
18
22
  function printHelp(): void {
19
23
  log.info(`Usage: appium-mcp [command] [options]
20
24
 
21
25
  Options:
22
- --httpStream Start with httpStream transport
23
- --port=<port> Port for httpStream transport (default: 8080)
24
- --plugin=<module> Load a plugin from a local path or installed package (repeatable)
25
- --help Show this help message`);
26
+ ${CLI_OPTIONS.httpStream} Start with httpStream transport
27
+ ${CLI_VALUE_PREFIXES.port}<port> Port for httpStream transport (default: ${DEFAULT_HTTP_STREAM_OPTIONS.port})
28
+ ${CLI_VALUE_PREFIXES.plugin}<module> Load a plugin from a local path or installed package (repeatable)
29
+ ${CLI_OPTIONS.help} Show this help message`);
26
30
  }
27
31
 
28
- async function startServer(args: string[]): Promise<void> {
29
- const useHttpStream = args.includes('--httpStream');
30
- const port = args.find((arg) => arg.startsWith('--port='))?.split('=')[1] || '8080';
32
+ async function startServer(args: readonly string[], useHttpStream: boolean): Promise<void> {
33
+ const port =
34
+ args.find((arg) => arg.startsWith(CLI_VALUE_PREFIXES.port))?.split('=')[1] ||
35
+ String(DEFAULT_HTTP_STREAM_OPTIONS.port);
31
36
 
32
37
  log.info('Starting MCP Appium MCP Server...');
33
38
 
@@ -36,26 +41,23 @@ async function startServer(args: string[]): Promise<void> {
36
41
  const {default: createDefaultServer} = await import('../server.js');
37
42
  const server = await createDefaultServer(plugins);
38
43
 
44
+ const startOptions: ServerStartOptions = useHttpStream
45
+ ? {
46
+ transportType: TRANSPORT_TYPES.httpStream,
47
+ httpStream: {...DEFAULT_HTTP_STREAM_OPTIONS, port: parseInt(port, 10)},
48
+ }
49
+ : {transportType: TRANSPORT_TYPES.stdio};
50
+ await server.start(startOptions);
51
+
39
52
  if (useHttpStream) {
40
- await server.start({
41
- transportType: 'httpStream',
42
- httpStream: {
43
- endpoint: '/sse',
44
- port: parseInt(port, 10),
45
- },
46
- });
47
-
48
- log.info(`Server started with httpStream transport on http://localhost:${port}/sse`);
49
- log.info('Waiting for client connections...');
53
+ log.info(
54
+ `Server started with httpStream transport on http://localhost:${port}${DEFAULT_HTTP_STREAM_OPTIONS.endpoint}`,
55
+ );
50
56
  } else {
51
- await server.start({
52
- transportType: 'stdio',
53
- });
54
-
55
57
  log.info('Server started with stdio transport');
56
- log.info('Waiting for client connections...');
57
58
  }
58
- } catch (error: any) {
59
+ log.info('Waiting for client connections...');
60
+ } catch (error: unknown) {
59
61
  log.error('Error starting server:', error);
60
62
  process.exit(1);
61
63
  }
@@ -0,0 +1,16 @@
1
+ export const CLI_COMMANDS = {
2
+ help: 'help',
3
+ } as const;
4
+
5
+ export const CLI_OPTIONS = {
6
+ help: '--help',
7
+ shortHelp: '-h',
8
+ httpStream: '--httpStream',
9
+ port: '--port',
10
+ plugin: '--plugin',
11
+ } as const;
12
+
13
+ export const CLI_VALUE_PREFIXES = {
14
+ port: `${CLI_OPTIONS.port}=`,
15
+ plugin: `${CLI_OPTIONS.plugin}=`,
16
+ } as const;
@@ -3,47 +3,82 @@ import {isAbsolute, resolve as resolvePath} from 'node:path';
3
3
  import {pathToFileURL} from 'node:url';
4
4
 
5
5
  import type {AppiumMcpPlugin} from '../core.js';
6
+ import {CLI_OPTIONS, CLI_VALUE_PREFIXES} from './options.js';
7
+
8
+ // Require a runtime check for every field in the plugin contract.
9
+ const PLUGIN_FIELD_TYPES = {
10
+ name: 'string',
11
+ version: 'string',
12
+ initialize: 'function',
13
+ register: 'function',
14
+ beforeCall: 'function',
15
+ afterCall: 'function',
16
+ destroy: 'function',
17
+ } as const satisfies {
18
+ [Key in keyof AppiumMcpPlugin]-?: NonNullable<AppiumMcpPlugin[Key]> extends string ? 'string' : 'function';
19
+ };
20
+
21
+ type ResolvePackage = (specifier: string) => string;
22
+ type PluginConstructor = new () => unknown;
6
23
 
7
24
  /** Load explicitly requested plugins in command-line order, relative to the caller. */
8
- export async function loadCliPlugins(args: string[], cwd = process.cwd()): Promise<AppiumMcpPlugin[]> {
25
+ export async function loadCliPlugins(args: readonly string[], cwd = process.cwd()): Promise<AppiumMcpPlugin[]> {
26
+ const specifiers = parsePluginSpecifiers(args);
27
+ const requireFromCwd = createRequire(resolvePath(cwd, 'package.json'));
28
+ const plugins: AppiumMcpPlugin[] = [];
29
+ for (const specifier of specifiers) {
30
+ // Imports and constructors can have side effects, so preserve flag order.
31
+ plugins.push(await loadPlugin(specifier, cwd, requireFromCwd.resolve));
32
+ }
33
+ return plugins;
34
+ }
35
+
36
+ function parsePluginSpecifiers(args: readonly string[]): string[] {
9
37
  const specifiers: string[] = [];
10
38
  for (let index = 0; index < args.length; index++) {
11
39
  const arg = args[index];
12
- if (arg !== '--plugin' && !arg.startsWith('--plugin=')) {
40
+ if (arg !== CLI_OPTIONS.plugin && !arg.startsWith(CLI_VALUE_PREFIXES.plugin)) {
13
41
  continue;
14
42
  }
15
- const specifier = arg === '--plugin' ? args[++index] : arg.slice('--plugin='.length);
43
+ const specifier = arg === CLI_OPTIONS.plugin ? args[++index] : arg.slice(CLI_VALUE_PREFIXES.plugin.length);
16
44
  if (!specifier?.trim() || specifier.startsWith('--')) {
17
- throw new Error('--plugin requires a module path or an installed package name.');
45
+ throw new Error(`${CLI_OPTIONS.plugin} requires a module path or an installed package name.`);
18
46
  }
19
47
  specifiers.push(specifier);
20
48
  }
21
49
 
22
- const plugins: AppiumMcpPlugin[] = [];
23
- const requireFromCwd = createRequire(resolvePath(cwd, 'package.json'));
24
- for (const specifier of specifiers) {
25
- try {
26
- const moduleSpecifier =
27
- isAbsolute(specifier) || specifier.startsWith('.')
28
- ? resolvePath(cwd, specifier)
29
- : URL.canParse(specifier)
30
- ? new URL(specifier).href
31
- : requireFromCwd.resolve(specifier);
32
- const moduleURL = isAbsolute(moduleSpecifier) ? pathToFileURL(moduleSpecifier).href : moduleSpecifier;
33
- if (!moduleURL.startsWith('file:')) {
34
- throw new Error('Only local files and installed packages are supported.');
35
- }
36
- const module = (await import(moduleURL)) as {default?: unknown};
37
- const exported = module.default;
38
- const plugin = typeof exported === 'function' ? new (exported as new () => unknown)() : exported;
39
- assertPlugin(plugin);
40
- plugins.push(plugin);
41
- } catch (error: unknown) {
42
- const message = error instanceof Error ? error.message : String(error);
43
- throw new Error(`Failed to load plugin "${specifier}": ${message}`, {cause: error});
44
- }
50
+ return specifiers;
51
+ }
52
+
53
+ function resolvePluginUrl(specifier: string, cwd: string, resolvePackage: ResolvePackage): string {
54
+ let moduleSpecifier: string;
55
+ if (isAbsolute(specifier) || specifier.startsWith('.')) {
56
+ moduleSpecifier = resolvePath(cwd, specifier);
57
+ } else if (URL.canParse(specifier)) {
58
+ moduleSpecifier = new URL(specifier).href;
59
+ } else {
60
+ moduleSpecifier = resolvePackage(specifier);
61
+ }
62
+
63
+ const moduleURL = isAbsolute(moduleSpecifier) ? pathToFileURL(moduleSpecifier).href : moduleSpecifier;
64
+ if (!moduleURL.startsWith('file:')) {
65
+ throw new Error('Only local files and installed packages are supported.');
66
+ }
67
+ return moduleURL;
68
+ }
69
+
70
+ async function loadPlugin(specifier: string, cwd: string, resolvePackage: ResolvePackage): Promise<AppiumMcpPlugin> {
71
+ try {
72
+ const moduleURL = resolvePluginUrl(specifier, cwd, resolvePackage);
73
+ const module = (await import(moduleURL)) as {default?: unknown};
74
+ const exported = module.default;
75
+ const plugin = typeof exported === 'function' ? new (exported as PluginConstructor)() : exported;
76
+ assertPlugin(plugin);
77
+ return plugin;
78
+ } catch (error: unknown) {
79
+ const message = error instanceof Error ? error.message : String(error);
80
+ throw new Error(`Failed to load plugin "${specifier}": ${message}`, {cause: error});
45
81
  }
46
- return plugins;
47
82
  }
48
83
 
49
84
  function assertPlugin(plugin: unknown): asserts plugin is AppiumMcpPlugin {
@@ -51,14 +86,14 @@ function assertPlugin(plugin: unknown): asserts plugin is AppiumMcpPlugin {
51
86
  throw new Error('The default export must be an AppiumMcpPlugin object or a class with a no-argument constructor.');
52
87
  }
53
88
  const candidate = plugin as Record<string, unknown>;
54
- for (const field of ['name', 'version']) {
55
- if (typeof candidate[field] !== 'string' || !candidate[field].trim()) {
56
- throw new Error(`The plugin must have a non-empty string "${field}".`);
57
- }
58
- }
59
- for (const hook of ['initialize', 'register', 'beforeCall', 'afterCall', 'destroy']) {
60
- if (candidate[hook] !== undefined && typeof candidate[hook] !== 'function') {
61
- throw new Error(`Plugin "${candidate.name}" has an invalid "${hook}" hook; expected a function.`);
89
+ for (const [field, expectedType] of Object.entries(PLUGIN_FIELD_TYPES)) {
90
+ const value = candidate[field];
91
+ if (expectedType === 'string') {
92
+ if (typeof value !== 'string' || !value.trim()) {
93
+ throw new Error(`The plugin must have a non-empty string "${field}".`);
94
+ }
95
+ } else if (value !== undefined && typeof value !== 'function') {
96
+ throw new Error(`Plugin "${candidate.name}" has an invalid "${field}" hook; expected a function.`);
62
97
  }
63
98
  }
64
99
  }
@@ -25,6 +25,7 @@ import {safeDeleteAllSessions, listSessions} from './session-store.js';
25
25
  import {initializeOpenTelemetry} from './telemetry/init.js';
26
26
  import {installTelemetryWrappers} from './telemetry/wrapOperations.js';
27
27
  import registerTools from './tools/index.js';
28
+ import {TRANSPORT_TYPES} from './transport.js';
28
29
 
29
30
  const SERVER_VERSION = pkg.version as `${number}.${number}.${number}`;
30
31
 
@@ -267,7 +268,7 @@ export async function createAppiumMcpServer(options: CreateAppiumMcpServerOption
267
268
  function wrapStartForStdioLogging(server: FastMCP): void {
268
269
  const originalStart = server.start.bind(server);
269
270
  server.start = (async (startOptions) => {
270
- if ((startOptions?.transportType ?? 'stdio') === 'stdio') {
271
+ if ((startOptions?.transportType ?? TRANSPORT_TYPES.stdio) === TRANSPORT_TYPES.stdio) {
271
272
  configureStdioTransportLogging();
272
273
  }
273
274
  return originalStart(startOptions);
@@ -125,9 +125,15 @@ async function resolveGlobalEntryUrl(): Promise<string | null> {
125
125
  const execDir = path.dirname(process.execPath);
126
126
  // npm global roots by platform (each entry is a resolution starting point,
127
127
  // so `<entry>/node_modules` is checked):
128
- // - POSIX (nvm, system, Homebrew): <prefix>/lib/node_modules
128
+ // - POSIX (nvm, system): <prefix>/lib/node_modules
129
129
  // - Windows (node.exe in <prefix>): <prefix>/node_modules
130
130
  const paths = [path.join(execDir, '..', 'lib'), execDir];
131
+ // Homebrew runs node from <prefix>/Cellar/node/<version>/bin but installs global
132
+ // packages into <prefix>/lib/node_modules.
133
+ const cellarIndex = execDir.lastIndexOf(`${path.sep}Cellar${path.sep}`);
134
+ if (cellarIndex !== -1) {
135
+ paths.push(path.join(execDir.slice(0, cellarIndex), 'lib'));
136
+ }
131
137
  const pkgJsonPath = require.resolve(`${PACKAGE_NAME}/package.json`, {
132
138
  paths,
133
139
  });
package/src/server.ts CHANGED
@@ -1,9 +1,13 @@
1
+ import type {FastMCP} from 'fastmcp';
2
+
1
3
  import type {AppiumMcpPlugin} from './core.js';
2
4
  import {createAppiumMcpServer} from './create-server.js';
3
5
  import {isDocumentationEnabled, loadDocumentationPlugin} from './documentation.js';
4
6
 
5
- export default async function createDefaultServer(additionalPlugins: AppiumMcpPlugin[] = []) {
6
- const plugins: AppiumMcpPlugin[] = [];
7
+ export default async function createDefaultServer(
8
+ additionalPlugins: readonly AppiumMcpPlugin[] = [],
9
+ ): Promise<FastMCP> {
10
+ const plugins = [...additionalPlugins];
7
11
 
8
12
  // Documentation tools (RAG docs query + skills) are opt-in. They live in a
9
13
  // separate package only installed when the user sets
@@ -11,9 +15,9 @@ export default async function createDefaultServer(additionalPlugins: AppiumMcpPl
11
15
  if (isDocumentationEnabled()) {
12
16
  const documentationPlugin = await loadDocumentationPlugin();
13
17
  if (documentationPlugin) {
14
- plugins.push(documentationPlugin);
18
+ plugins.unshift(documentationPlugin);
15
19
  }
16
20
  }
17
21
 
18
- return await createAppiumMcpServer({plugins: [...plugins, ...additionalPlugins]});
22
+ return createAppiumMcpServer({plugins});
19
23
  }
@@ -0,0 +1,13 @@
1
+ import type {FastMCP} from 'fastmcp';
2
+
3
+ export type ServerStartOptions = NonNullable<Parameters<FastMCP['start']>[0]>;
4
+
5
+ export const TRANSPORT_TYPES = {
6
+ stdio: 'stdio',
7
+ httpStream: 'httpStream',
8
+ } as const satisfies Record<string, ServerStartOptions['transportType']>;
9
+
10
+ export const DEFAULT_HTTP_STREAM_OPTIONS = {
11
+ endpoint: '/sse',
12
+ port: 8080,
13
+ } as const satisfies NonNullable<ServerStartOptions['httpStream']>;