@mobilenext/mobile-mcp 1.0.11 → 1.0.12

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/lib/android.js CHANGED
@@ -374,7 +374,9 @@ class AndroidRobot {
374
374
  }
375
375
  escapeShellText(text) {
376
376
  // escape all shell special characters that could be used for injection
377
- return text.replace(/[\\'"` \t\n\r|&;()<>{}[\]$*?]/g, "\\$&");
377
+ // # and ~ are also escaped: they start a comment / a home-path expansion
378
+ // when they open a word, and a backslash before them is inert elsewhere.
379
+ return text.replace(/[\\'"` \t\n\r|&;()<>{}[\]$*?#~]/g, "\\$&");
378
380
  }
379
381
  async isDeviceKitInstalled() {
380
382
  const packages = await this.listPackages();
@@ -122,10 +122,14 @@ class MobileDevice {
122
122
  }
123
123
  async getForegroundApp() {
124
124
  const response = this.runJsonCommand(["apps", "foreground"]);
125
- return {
125
+ const app = {
126
126
  appName: response.data.appName || response.data.packageName,
127
127
  packageName: response.data.packageName,
128
128
  };
129
+ if (response.data.activity) {
130
+ app.activity = response.data.activity;
131
+ }
132
+ return app;
129
133
  }
130
134
  async launchApp(packageName, locale) {
131
135
  const args = ["apps", "launch", packageName];
package/lib/mobilecli.js CHANGED
@@ -18,7 +18,7 @@ class Mobilecli {
18
18
  }
19
19
  executeCommand(args, timeoutMs) {
20
20
  const path = this.getPath();
21
- const options = { encoding: "utf8" };
21
+ const options = { encoding: "utf8", maxBuffer: MAX_BUFFER_SIZE };
22
22
  if (timeoutMs !== undefined) {
23
23
  options.timeout = timeoutMs;
24
24
  }
package/lib/server.js CHANGED
@@ -444,7 +444,7 @@ const createMcpServer = () => {
444
444
  const result = await robot.listApps();
445
445
  return `Found these apps on device: ${result.map(app => `${app.appName} (${app.packageName})`).join(", ")}`;
446
446
  });
447
- tool("mobile_get_foreground_app", "Get Foreground App", "Get the app currently in the foreground on the device. Use this to verify which app or screen you are on before interacting with it.", {
447
+ tool("mobile_get_foreground_app", "Get Foreground App", "Get the app currently in the foreground on the device, including the focused activity class on Android or view controller class on iOS when available. Use this to verify which app or screen you are on before interacting with it.", {
448
448
  device: zod_1.z.string().describe("The device identifier to use. Use mobile_list_available_devices to find which devices are available to you.")
449
449
  }, { readOnlyHint: true, openWorldHint: false }, async ({ device }) => {
450
450
  const robot = getRobotFromDevice(device);
@@ -452,7 +452,8 @@ const createMcpServer = () => {
452
452
  throw new robot_1.ActionableError("Getting the foreground app is not supported in legacy robot mode");
453
453
  }
454
454
  const app = await robot.getForegroundApp();
455
- return `Foreground app: ${app.appName} (${app.packageName})`;
455
+ const activity = app.activity ? `, activity: ${app.activity}` : "";
456
+ return `Foreground app: ${app.appName} (${app.packageName})${activity}`;
456
457
  });
457
458
  tool("mobile_launch_app", "Launch App", "Launch an app on mobile device. Use this to open a specific app. You can find the package name of the app by calling mobile_list_apps.", {
458
459
  device: zod_1.z.string().describe("The device identifier to use. Use mobile_list_available_devices to find which devices are available to you."),
@@ -597,10 +598,13 @@ const createMcpServer = () => {
597
598
  tool("mobile_swipe_on_screen", "Swipe Screen", "Swipe on the screen", {
598
599
  device: zod_1.z.string().describe("The device identifier to use. Use mobile_list_available_devices to find which devices are available to you."),
599
600
  direction: zod_1.z.enum(["up", "down", "left", "right"]).describe("The direction to swipe"),
600
- x: zod_1.z.coerce.number().min(0).optional().describe("The x coordinate to start the swipe from, in pixels. If not provided, uses center of screen"),
601
- y: zod_1.z.coerce.number().min(0).optional().describe("The y coordinate to start the swipe from, in pixels. If not provided, uses center of screen"),
601
+ x: zod_1.z.coerce.number().min(0).optional().describe("The x coordinate to start the swipe from, in pixels. Give both x and y, or neither to start from the center of screen"),
602
+ y: zod_1.z.coerce.number().min(0).optional().describe("The y coordinate to start the swipe from, in pixels. Give both x and y, or neither to start from the center of screen"),
602
603
  distance: zod_1.z.coerce.number().min(1).optional().describe("The distance to swipe in pixels. Defaults to 400 pixels for iOS or 30% of screen dimension for Android"),
603
604
  }, { readOnlyHint: false, destructiveHint: false, openWorldHint: true }, async ({ device, direction, x, y, distance }) => {
605
+ if ((x === undefined) !== (y === undefined)) {
606
+ throw new robot_1.ActionableError("Provide both x and y to start the swipe from a point, or neither to start from the center of the screen");
607
+ }
604
608
  const robot = getRobotFromDevice(device);
605
609
  if (x !== undefined && y !== undefined) {
606
610
  // Use coordinate-based swipe
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mobilenext/mobile-mcp",
3
3
  "mcpName": "io.github.mobile-next/mobile-mcp",
4
- "version": "1.0.11",
4
+ "version": "1.0.12",
5
5
  "description": "Mobile MCP",
6
6
  "repository": {
7
7
  "type": "git",
@@ -32,7 +32,7 @@
32
32
  "commander": "14.0.0",
33
33
  "express": "5.1.0",
34
34
  "fast-xml-parser": "5.8.0",
35
- "mobilewright": "0.0.66",
35
+ "mobilewright": "0.0.67",
36
36
  "qs": "^6.15.0",
37
37
  "zod": "^4.2.0",
38
38
  "zod-to-json-schema": "3.25.0"