@mobilenext/mobile-mcp 1.0.11 → 1.0.13

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
@@ -261,7 +261,8 @@ const createMcpServer = () => {
261
261
  // ponytail: same tool as @posthog/mcp's reportMissing, without pulling in the sdk
262
262
  // nothing to report to when telemetry is off, so don't advertise the tool at all
263
263
  if (!process.env.MOBILEMCP_DISABLE_TELEMETRY) {
264
- tool("get_more_tools", "Get More Tools", "Check for additional tools whenever your task might benefit from specialized capabilities - even if existing tools could work as a fallback. " +
264
+ tool("get_more_tools", "Get More Tools", "Only call this when none of the other tools can do what you need on a mobile device, or for mobile testing or mobile app development. " +
265
+ "Do not call it for tasks unrelated to mobile, or when another tool already covers the task. " +
265
266
  "The context is sent to the mobile-mcp developers, so never include PII, secrets, credentials or other private information in it.", {
266
267
  context: zod_1.z.string().describe("A description of your goal and what kind of tool would help accomplish it."),
267
268
  }, { readOnlyHint: true, openWorldHint: true }, async ({ context }) => {
@@ -444,7 +445,7 @@ const createMcpServer = () => {
444
445
  const result = await robot.listApps();
445
446
  return `Found these apps on device: ${result.map(app => `${app.appName} (${app.packageName})`).join(", ")}`;
446
447
  });
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.", {
448
+ 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
449
  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
450
  }, { readOnlyHint: true, openWorldHint: false }, async ({ device }) => {
450
451
  const robot = getRobotFromDevice(device);
@@ -452,7 +453,8 @@ const createMcpServer = () => {
452
453
  throw new robot_1.ActionableError("Getting the foreground app is not supported in legacy robot mode");
453
454
  }
454
455
  const app = await robot.getForegroundApp();
455
- return `Foreground app: ${app.appName} (${app.packageName})`;
456
+ const activity = app.activity ? `, activity: ${app.activity}` : "";
457
+ return `Foreground app: ${app.appName} (${app.packageName})${activity}`;
456
458
  });
457
459
  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
460
  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 +599,13 @@ const createMcpServer = () => {
597
599
  tool("mobile_swipe_on_screen", "Swipe Screen", "Swipe on the screen", {
598
600
  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
601
  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"),
602
+ 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"),
603
+ 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
604
  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
605
  }, { readOnlyHint: false, destructiveHint: false, openWorldHint: true }, async ({ device, direction, x, y, distance }) => {
606
+ if ((x === undefined) !== (y === undefined)) {
607
+ 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");
608
+ }
604
609
  const robot = getRobotFromDevice(device);
605
610
  if (x !== undefined && y !== undefined) {
606
611
  // 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.13",
5
5
  "description": "Mobile MCP",
6
6
  "repository": {
7
7
  "type": "git",
@@ -25,14 +25,14 @@
25
25
  "lib"
26
26
  ],
27
27
  "dependencies": {
28
- "@modelcontextprotocol/express": "2.0.0",
28
+ "@modelcontextprotocol/express": "2.0.2",
29
29
  "@modelcontextprotocol/node": "2.0.0",
30
- "@modelcontextprotocol/server": "2.0.0",
30
+ "@modelcontextprotocol/server": "2.4.0",
31
31
  "ajv": "^8.18.0",
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"