appium-mcp 1.93.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,19 @@
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
+
11
+ ## [1.94.0](https://github.com/appium/appium-mcp/compare/v1.93.0...v1.94.0) (2026-09-10)
12
+
13
+ ### Features
14
+
15
+ * load plugins from the command line ([#525](https://github.com/appium/appium-mcp/issues/525)) ([5eb1b99](https://github.com/appium/appium-mcp/commit/5eb1b9930836a85ba9ea2fd786e234d35a28e6e0))
16
+
1
17
  ## [1.93.0](https://github.com/appium/appium-mcp/compare/v1.92.14...v1.93.0) (2026-09-07)
2
18
 
3
19
  ### 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
 
@@ -488,6 +488,41 @@ Treat this setting as an additional deployment safeguard. Network-level controls
488
488
 
489
489
  ## 🔌 Plugin API
490
490
 
491
+ ### Load plugins from the command line
492
+
493
+ Pass `--plugin` to start the standard server with a plugin, without writing a server bootstrap module. Repeat the option to load multiple plugins in order; both `--plugin <module>` and `--plugin=<module>` work with stdio and `--httpStream`:
494
+
495
+ ```bash
496
+ appium-mcp --plugin ./checkout-plugin.mjs --plugin=@acme/appium-mcp-plugin
497
+ ```
498
+
499
+ Each module must **default-export** either an `AppiumMcpPlugin` object or a plugin class whose constructor takes no arguments. For example, save this as `checkout-plugin.mjs`:
500
+
501
+ ```javascript
502
+ export default class CheckoutPlugin {
503
+ name = 'checkout-plugin';
504
+ version = '1.0.0';
505
+
506
+ register(registry) {
507
+ registry.addTool({
508
+ name: 'checkout_status',
509
+ description: 'Return the checkout integration status.',
510
+ execute: async () => ({content: [{type: 'text', text: 'Checkout plugin ready'}]}),
511
+ });
512
+ }
513
+ }
514
+ ```
515
+
516
+ Use an exported object (for example, `export default new CheckoutPlugin(options)`) when a plugin needs constructor options. TypeScript plugins must be compiled to JavaScript before loading.
517
+
518
+ Relative paths and installed package names resolve from the working directory where `appium-mcp` is launched. Package names use Node's CommonJS resolution (`createRequire(...).resolve()`), including `require` or `default` export conditions and legacy `main` entries. Packages exposing only an `import` export must be loaded through an explicit file path (for example, `--plugin ./node_modules/my-plugin/plugin.mjs`) or a `file:` URL. Loading still uses dynamic `import()`, so ESM plugin files, including those with top-level `await`, remain supported.
519
+
520
+ Absolute paths and `file:` URLs are also accepted; absolute paths are recommended in MCP client configurations because the client's working directory can vary. The CLI does not install packages: install package plugins in that working directory first.
521
+
522
+ Plugins execute in the server process, so load only trusted files and packages and keep plugin logs on stderr when using stdio. A missing module or invalid plugin export stops startup with an error instead of silently omitting the plugin. The optional documentation plugin, when enabled, is registered before CLI plugins. The existing duplicate-name and lifecycle rules below apply.
523
+
524
+ ### Compose a server programmatically
525
+
491
526
  Use `appium-mcp/core` to compose the default Appium MCP server with custom business logic without maintaining a fork. Plugins can register MCP tools, prompts, resources, and resource templates, and can wrap tool execution with lifecycle hooks. Call hooks are tool-only: prompts, resources, and resource templates are registered with FastMCP but are not wrapped by `beforeCall` or `afterCall`.
492
527
 
493
528
  `createAppiumMcpServer({ policy })` can also hide nonmatching tools and resources from MCP discovery. The factory is async, so await it before starting the returned server. Policy rules are regular expressions matched against tool and resource names exactly as registered. The policy is applied at registration time to both single and batch registration methods. Resource policy matches the resource `name` only; resources or resource templates without a string `name` cannot match a non-empty `allowResources` list.
@@ -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":"AAEA,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,47 +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';
4
+ import { loadCliPlugins } from './plugins.js';
2
5
  export async function runCli(args = process.argv.slice(2)) {
3
6
  const command = args[0];
4
- if (command === '--help' || command === '-h' || command === 'help') {
7
+ if (command === CLI_OPTIONS.help || command === CLI_OPTIONS.shortHelp || command === CLI_COMMANDS.help) {
5
8
  printHelp();
6
9
  return;
7
10
  }
8
- if (!args.includes('--httpStream')) {
11
+ const useHttpStream = args.includes(CLI_OPTIONS.httpStream);
12
+ if (!useHttpStream) {
9
13
  configureStdioTransportLogging();
10
14
  }
11
- await startServer(args);
15
+ await startServer(args, useHttpStream);
12
16
  }
13
17
  function printHelp() {
14
18
  log.info(`Usage: appium-mcp [command] [options]
15
19
 
16
20
  Options:
17
- --httpStream Start with httpStream transport
18
- --port=<port> Port for httpStream transport (default: 8080)
19
- --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`);
20
25
  }
21
- async function startServer(args) {
22
- const useHttpStream = args.includes('--httpStream');
23
- 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);
24
29
  log.info('Starting MCP Appium MCP Server...');
25
30
  try {
26
- const { default: server } = await import('../server.js');
31
+ const plugins = await loadCliPlugins(args);
32
+ const { default: createDefaultServer } = await import('../server.js');
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);
27
41
  if (useHttpStream) {
28
- await server.start({
29
- transportType: 'httpStream',
30
- httpStream: {
31
- endpoint: '/sse',
32
- port: parseInt(port, 10),
33
- },
34
- });
35
- log.info(`Server started with httpStream transport on http://localhost:${port}/sse`);
36
- log.info('Waiting for client connections...');
42
+ log.info(`Server started with httpStream transport on http://localhost:${port}${DEFAULT_HTTP_STREAM_OPTIONS.endpoint}`);
37
43
  }
38
44
  else {
39
- await server.start({
40
- transportType: 'stdio',
41
- });
42
45
  log.info('Server started with stdio transport');
43
- log.info('Waiting for client connections...');
44
46
  }
47
+ log.info('Waiting for client connections...');
45
48
  }
46
49
  catch (error) {
47
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;AAEjE,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAiB,OAAO,CAAC,IAAI,CAAC,KAA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C;QACJ,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;QAClD,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;IAChD,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,GAAG,CAAC,KAAK,CAAC,wBAAwB,EAAE,KAAK,CAAC,CAAC;QAC3C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
@@ -0,0 +1,15 @@
1
+ export declare const CLI_COMMANDS: {
2
+ 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"}
@@ -0,0 +1,4 @@
1
+ import type { AppiumMcpPlugin } from '../core.js';
2
+ /** Load explicitly requested plugins in command-line order, relative to the caller. */
3
+ export declare function loadCliPlugins(args: readonly string[], cwd?: string): Promise<AppiumMcpPlugin[]>;
4
+ //# sourceMappingURL=plugins.d.ts.map
@@ -0,0 +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;AAmBhD,uFAAuF;AACvF,wBAAsB,cAAc,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,SAAgB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAS7G"}
@@ -0,0 +1,89 @@
1
+ import { createRequire } from 'node:module';
2
+ import { isAbsolute, resolve as resolvePath } from 'node:path';
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
+ };
15
+ /** Load explicitly requested plugins in command-line order, relative to the caller. */
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) {
27
+ const specifiers = [];
28
+ for (let index = 0; index < args.length; index++) {
29
+ const arg = args[index];
30
+ if (arg !== CLI_OPTIONS.plugin && !arg.startsWith(CLI_VALUE_PREFIXES.plugin)) {
31
+ continue;
32
+ }
33
+ const specifier = arg === CLI_OPTIONS.plugin ? args[++index] : arg.slice(CLI_VALUE_PREFIXES.plugin.length);
34
+ if (!specifier?.trim() || specifier.startsWith('--')) {
35
+ throw new Error(`${CLI_OPTIONS.plugin} requires a module path or an installed package name.`);
36
+ }
37
+ specifiers.push(specifier);
38
+ }
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 });
70
+ }
71
+ }
72
+ function assertPlugin(plugin) {
73
+ if (typeof plugin !== 'object' || plugin === null) {
74
+ throw new Error('The default export must be an AppiumMcpPlugin object or a class with a no-argument constructor.');
75
+ }
76
+ const candidate = plugin;
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
+ }
83
+ }
84
+ else if (value !== undefined && typeof value !== 'function') {
85
+ throw new Error(`Plugin "${candidate.name}" has an invalid "${field}" hook; expected a function.`);
86
+ }
87
+ }
88
+ }
89
+ //# sourceMappingURL=plugins.js.map
@@ -0,0 +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;AAGvC,OAAO,EAAC,WAAW,EAAE,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAE7D,kEAAkE;AAClE,MAAM,kBAAkB,GAAG;IACzB,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,QAAQ;IACjB,UAAU,EAAE,UAAU;IACtB,QAAQ,EAAE,UAAU;IACpB,UAAU,EAAE,UAAU;IACtB,SAAS,EAAE,UAAU;IACrB,OAAO,EAAE,UAAU;CAGpB,CAAC;AAKF,uFAAuF;AACvF,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAuB,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE;IAC/E,MAAM,UAAU,GAAG,qBAAqB,CAAC,IAAI,CAA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Sessions } 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,EAAC,CAAC;AACtD,OAAO,GAAG,EAAE,EAAC,8BAA8B,EAAC,MAAM,aAAa,CAAC;AAChE,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAE1C,OAAO,EAAC,aAAa,EAAuB,MAAM,aAAa,CAAC;AAChE,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAC,qBAAqB,EAAE,YAAY,EAAC,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAC,uBAAuB,EAAC,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAC,wBAAwB,EAAC,MAAM,+BAA+B,CAAC;AACvE,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,MAAM,cAAc,GAAG,GAAG,CAAC,OAA0C,CAAC;AAEtE,MAA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IAC/B,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,wBAAwB,CAAC,MAAe;IAC/C,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAChD,MAAM,CAAC,KAAK,GAAG,CAAC,KAAK,EAAE,YAAY,EAAE,EAAE;QACrC,IAAI,CAAC,YAAY,EAAE,aAAa,IAAI,eAAe,CAAC,KAAK,CAAC,KAAK,eAAe,CAAC,KAAK,EAAE,CAAC;YACrF,8BAA8B,EAAE,CAAC;QACnC,CAAC;QACD,OAAO,aAAa,CAAC,YAAY,CAAC,CAAC;IACrC,CAAC,CAAqB,CAAC;AACzB,CAAC;AAED,SAAS,8BAA8B;IACrC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC,+BAA+B,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC9E,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;QACnB,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,GAAG,KAAK,YAAY,EAAE,CAAC;QACzB,GAAG,CAAC,IAAI,CAAC,oCAAoC,GAAG,+CAA+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;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB;IAC3C,IAAI,GAA+B,CAAC;IACpC,IAAI,CAAC;QACH,GAAG,GAAG,MAAM,yBAAyB,EAAE,CAAC;IAC1C,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,2EAA2E;QAC3E,GAAG,CAAC,KAAK,CAAC,GAAG,YAAY,mCAAmC,EAAE,GAAG,CAAC,CAAC;QACnE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,GAAG,CAAC,IAAI,CACN,GAAG,YAAY,eAAe,YAAY,uBAAuB;YAC/D,sEAAsE;YACtE,oEAAoE;YACpE,yEAAyE;YACzE,wBAAwB,YAAY,IAAI;YACxC,qFAAqF;YACrF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,MAAM,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,CAG5D,CAAC;QACF,MAAM,aAAa,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,IAAI,GAAG,CAAC,IAAI,IAAI,UAAU,CAAC;QAC1G,OAAO,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,GAAY;IACpC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,CAAC,CAAC,MAAM,IAAI,GAAG,CAAC,EAAE,CAAC;QAChE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,IAAI,GAAI,GAAwB,CAAC,IAAI,CAAC;IAC5C,OAAO,IAAI,KAAK,sBAAsB,IAAI,IAAI,KAAK,kBAAkB,CAAC;AACxE,CAAC"}
package/dist/server.d.ts CHANGED
@@ -1,3 +1,4 @@
1
- declare const server: import("fastmcp").FastMCP<import("fastmcp").FastMCPSessionAuth>;
2
- export default server;
1
+ import type { FastMCP } from 'fastmcp';
2
+ import type { AppiumMcpPlugin } from './core.js';
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":"AAgBA,QAAA,MAAM,MAAM,iEAAyC,CAAC;AACtD,eAAe,MAAM,CAAC"}
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,15 +1,16 @@
1
1
  import { createAppiumMcpServer } from './create-server.js';
2
2
  import { isDocumentationEnabled, loadDocumentationPlugin } from './documentation.js';
3
- const plugins = [];
4
- // Documentation tools (RAG docs query + skills) are opt-in. They live in a
5
- // separate package only installed when the user sets
6
- // APPIUM_MCP_DOCS_ENABLED. See ./documentation.ts for the full contract.
7
- if (isDocumentationEnabled()) {
8
- const documentationPlugin = await loadDocumentationPlugin();
9
- if (documentationPlugin) {
10
- plugins.push(documentationPlugin);
3
+ export default async function createDefaultServer(additionalPlugins = []) {
4
+ const plugins = [...additionalPlugins];
5
+ // Documentation tools (RAG docs query + skills) are opt-in. They live in a
6
+ // separate package only installed when the user sets
7
+ // APPIUM_MCP_DOCS_ENABLED. See ./documentation.ts for the full contract.
8
+ if (isDocumentationEnabled()) {
9
+ const documentationPlugin = await loadDocumentationPlugin();
10
+ if (documentationPlugin) {
11
+ plugins.unshift(documentationPlugin);
12
+ }
11
13
  }
14
+ return createAppiumMcpServer({ plugins });
12
15
  }
13
- const server = await createAppiumMcpServer({ plugins });
14
- export default server;
15
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,OAAO,GAAsB,EAAE,CAAC;AAEtC,2EAA2E;AAC3E,qDAAqD;AACrD,yEAAyE;AACzE,IAAI,sBAAsB,EAAE,EAAE,CAAC;IAC7B,MAAM,mBAAmB,GAAG,MAAM,uBAAuB,EAAE,CAAC;IAC5D,IAAI,mBAAmB,EAAE,CAAC;QACxB,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IACpC,CAAC;AACH,CAAC;AAED,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,EAAC,OAAO,EAAC,CAAC,CAAC;AACtD,eAAe,MAAM,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.93.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.93.0",
6
+ "version": "1.94.1",
7
7
  "packages": [
8
8
  {
9
9
  "registryType": "npm",
10
10
  "identifier": "appium-mcp",
11
- "version": "1.93.0",
11
+ "version": "1.94.1",
12
12
  "transport": {
13
13
  "type": "stdio"
14
14
  }
package/src/cli/index.ts CHANGED
@@ -1,57 +1,63 @@
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';
5
+ import {loadCliPlugins} from './plugins.js';
2
6
 
3
- 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> {
4
8
  const command = args[0];
5
- if (command === '--help' || command === '-h' || command === 'help') {
9
+ if (command === CLI_OPTIONS.help || command === CLI_OPTIONS.shortHelp || command === CLI_COMMANDS.help) {
6
10
  printHelp();
7
11
  return;
8
12
  }
9
13
 
10
- if (!args.includes('--httpStream')) {
14
+ const useHttpStream = args.includes(CLI_OPTIONS.httpStream);
15
+ if (!useHttpStream) {
11
16
  configureStdioTransportLogging();
12
17
  }
13
18
 
14
- await startServer(args);
19
+ await startServer(args, useHttpStream);
15
20
  }
16
21
 
17
22
  function printHelp(): void {
18
23
  log.info(`Usage: appium-mcp [command] [options]
19
24
 
20
25
  Options:
21
- --httpStream Start with httpStream transport
22
- --port=<port> Port for httpStream transport (default: 8080)
23
- --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`);
24
30
  }
25
31
 
26
- async function startServer(args: string[]): Promise<void> {
27
- const useHttpStream = args.includes('--httpStream');
28
- 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);
29
36
 
30
37
  log.info('Starting MCP Appium MCP Server...');
31
38
 
32
39
  try {
33
- const {default: server} = await import('../server.js');
40
+ const plugins = await loadCliPlugins(args);
41
+ const {default: createDefaultServer} = await import('../server.js');
42
+ const server = await createDefaultServer(plugins);
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);
34
51
 
35
52
  if (useHttpStream) {
36
- await server.start({
37
- transportType: 'httpStream',
38
- httpStream: {
39
- endpoint: '/sse',
40
- port: parseInt(port, 10),
41
- },
42
- });
43
-
44
- log.info(`Server started with httpStream transport on http://localhost:${port}/sse`);
45
- 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
+ );
46
56
  } else {
47
- await server.start({
48
- transportType: 'stdio',
49
- });
50
-
51
57
  log.info('Server started with stdio transport');
52
- log.info('Waiting for client connections...');
53
58
  }
54
- } catch (error: any) {
59
+ log.info('Waiting for client connections...');
60
+ } catch (error: unknown) {
55
61
  log.error('Error starting server:', error);
56
62
  process.exit(1);
57
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;
@@ -0,0 +1,99 @@
1
+ import {createRequire} from 'node:module';
2
+ import {isAbsolute, resolve as resolvePath} from 'node:path';
3
+ import {pathToFileURL} from 'node:url';
4
+
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;
23
+
24
+ /** Load explicitly requested plugins in command-line order, relative to the caller. */
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[] {
37
+ const specifiers: string[] = [];
38
+ for (let index = 0; index < args.length; index++) {
39
+ const arg = args[index];
40
+ if (arg !== CLI_OPTIONS.plugin && !arg.startsWith(CLI_VALUE_PREFIXES.plugin)) {
41
+ continue;
42
+ }
43
+ const specifier = arg === CLI_OPTIONS.plugin ? args[++index] : arg.slice(CLI_VALUE_PREFIXES.plugin.length);
44
+ if (!specifier?.trim() || specifier.startsWith('--')) {
45
+ throw new Error(`${CLI_OPTIONS.plugin} requires a module path or an installed package name.`);
46
+ }
47
+ specifiers.push(specifier);
48
+ }
49
+
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});
81
+ }
82
+ }
83
+
84
+ function assertPlugin(plugin: unknown): asserts plugin is AppiumMcpPlugin {
85
+ if (typeof plugin !== 'object' || plugin === null) {
86
+ throw new Error('The default export must be an AppiumMcpPlugin object or a class with a no-argument constructor.');
87
+ }
88
+ const candidate = plugin as Record<string, unknown>;
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.`);
97
+ }
98
+ }
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,18 +1,23 @@
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
- const plugins: AppiumMcpPlugin[] = [];
7
+ export default async function createDefaultServer(
8
+ additionalPlugins: readonly AppiumMcpPlugin[] = [],
9
+ ): Promise<FastMCP> {
10
+ const plugins = [...additionalPlugins];
6
11
 
7
- // Documentation tools (RAG docs query + skills) are opt-in. They live in a
8
- // separate package only installed when the user sets
9
- // APPIUM_MCP_DOCS_ENABLED. See ./documentation.ts for the full contract.
10
- if (isDocumentationEnabled()) {
11
- const documentationPlugin = await loadDocumentationPlugin();
12
- if (documentationPlugin) {
13
- plugins.push(documentationPlugin);
12
+ // Documentation tools (RAG docs query + skills) are opt-in. They live in a
13
+ // separate package only installed when the user sets
14
+ // APPIUM_MCP_DOCS_ENABLED. See ./documentation.ts for the full contract.
15
+ if (isDocumentationEnabled()) {
16
+ const documentationPlugin = await loadDocumentationPlugin();
17
+ if (documentationPlugin) {
18
+ plugins.unshift(documentationPlugin);
19
+ }
14
20
  }
15
- }
16
21
 
17
- const server = await createAppiumMcpServer({plugins});
18
- export default server;
22
+ return createAppiumMcpServer({plugins});
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']>;