@mobilenext/mobile-mcp 1.0.14 → 1.0.15
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/README.ja.md +1 -1
- package/README.md +2 -1
- package/README.zh-CN.md +1 -1
- package/lib/mobile-device.js +3 -0
- package/lib/server.js +11 -0
- package/lib/utils.js +22 -9
- package/package.json +2 -2
package/README.ja.md
CHANGED
|
@@ -419,7 +419,7 @@ test('sign in', async ({ screen }) => {
|
|
|
419
419
|
});
|
|
420
420
|
```
|
|
421
421
|
|
|
422
|
-
`npm init mobilewright@latest`
|
|
422
|
+
`npm init mobilewright@latest` から始めましょう。エージェントのセッションから GitHub Actions で動くテストまでの流れは[ステップバイステップガイド](docs/mobilewright-ci.md)(英語)をご覧ください。
|
|
423
423
|
|
|
424
424
|
### ☁️ クラウドデバイスでスケールする
|
|
425
425
|
|
package/README.md
CHANGED
|
@@ -118,6 +118,7 @@ How we help to scale mobile automation:
|
|
|
118
118
|
- **`mobile_terminate_app`** - Stop and terminate a running app
|
|
119
119
|
- **`mobile_install_app`** - Install an app from file (.apk, .ipa, .app, .zip)
|
|
120
120
|
- **`mobile_uninstall_app`** - Uninstall an app by its package name or bundle ID
|
|
121
|
+
- **`mobile_clear_app_data`** - Clear an app's data so it starts fresh (Android and iOS Simulator)
|
|
121
122
|
|
|
122
123
|
### Screen Interaction
|
|
123
124
|
- **`mobile_take_screenshot`** - Take a screenshot to understand what's on screen
|
|
@@ -429,7 +430,7 @@ test('sign in', async ({ screen }) => {
|
|
|
429
430
|
});
|
|
430
431
|
```
|
|
431
432
|
|
|
432
|
-
Start with `npm init mobilewright@latest`.
|
|
433
|
+
Start with `npm init mobilewright@latest`. The [step-by-step guide](docs/mobilewright-ci.md) goes from an agent session to a test running in GitHub Actions.
|
|
433
434
|
|
|
434
435
|
### ☁️ Scale up, use a cloud device
|
|
435
436
|
|
package/README.zh-CN.md
CHANGED
package/lib/mobile-device.js
CHANGED
|
@@ -141,6 +141,9 @@ class MobileDevice {
|
|
|
141
141
|
async terminateApp(packageName) {
|
|
142
142
|
this.runCommand(["apps", "terminate", packageName]);
|
|
143
143
|
}
|
|
144
|
+
async clearAppData(packageName) {
|
|
145
|
+
this.runCommand(["apps", "clear", packageName]);
|
|
146
|
+
}
|
|
144
147
|
async installApp(path) {
|
|
145
148
|
this.runCommand(["apps", "install", path]);
|
|
146
149
|
}
|
package/lib/server.js
CHANGED
|
@@ -473,6 +473,17 @@ const createMcpServer = () => {
|
|
|
473
473
|
await robot.terminateApp(packageName);
|
|
474
474
|
return `Terminated app ${packageName}`;
|
|
475
475
|
});
|
|
476
|
+
tool("mobile_clear_app_data", "Clear App Data", "Clear an app's data, such as its cache, documents, preferences and databases, and stop the app, so the next launch starts as if freshly installed. The app stays installed. Supported on Android devices and emulators and on iOS simulators, not on real iOS devices.", {
|
|
477
|
+
device: zod_1.z.string().describe("The device identifier to use. Use mobile_list_available_devices to find which devices are available to you."),
|
|
478
|
+
packageName: zod_1.z.string().describe("The package name (Android) or bundle id (iOS) of the app to clear"),
|
|
479
|
+
}, { readOnlyHint: false, destructiveHint: true, openWorldHint: false }, async ({ device, packageName }) => {
|
|
480
|
+
const robot = getRobotFromDevice(device);
|
|
481
|
+
if (!robot.clearAppData) {
|
|
482
|
+
throw new robot_1.ActionableError("Clearing app data is not supported in legacy robot mode");
|
|
483
|
+
}
|
|
484
|
+
await robot.clearAppData(packageName);
|
|
485
|
+
return `Cleared app data for ${packageName}`;
|
|
486
|
+
});
|
|
476
487
|
tool("mobile_install_app", "Install App", "Install an app on mobile device", {
|
|
477
488
|
device: zod_1.z.string().describe("The device identifier to use. Use mobile_list_available_devices to find which devices are available to you."),
|
|
478
489
|
path: zod_1.z.string().describe("The path to the app file to install. For iOS simulators, provide a .zip file or a .app directory. For Android provide an .apk file. For iOS real devices provide an .ipa file"),
|
package/lib/utils.js
CHANGED
|
@@ -15,6 +15,7 @@ exports.finishRecording = finishRecording;
|
|
|
15
15
|
const node_path_1 = __importDefault(require("node:path"));
|
|
16
16
|
const node_os_1 = __importDefault(require("node:os"));
|
|
17
17
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
18
|
+
const node_crypto_1 = require("node:crypto");
|
|
18
19
|
const robot_1 = require("./robot");
|
|
19
20
|
function validatePackageName(packageName) {
|
|
20
21
|
// iOS bundle identifiers (which flow through this same "packageName" parameter
|
|
@@ -145,17 +146,29 @@ function validateOutputPath(filePath) {
|
|
|
145
146
|
throw new robot_1.ActionableError(`"${dir}" is not in the list of allowed directories. Allowed directories: ${allowedRoots.join(", ")}.`);
|
|
146
147
|
}
|
|
147
148
|
}
|
|
148
|
-
//
|
|
149
|
-
// link planted
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
// a sibling of `to` with an unguessable name, created with O_EXCL ("wx"), so a
|
|
150
|
+
// file or link planted there makes the write fail instead of redirecting it
|
|
151
|
+
function partialPathFor(to) {
|
|
152
|
+
return node_path_1.default.join(node_path_1.default.dirname(to), `.${node_path_1.default.basename(to)}.${(0, node_crypto_1.randomBytes)(8).toString("hex")}.partial`);
|
|
153
|
+
}
|
|
154
|
+
// write next to `filePath` and rename over it: rename replaces whatever sits at
|
|
155
|
+
// `filePath` (a symlink, a hard link, a regular file) instead of writing through
|
|
156
|
+
// it, so a link can never point the write at another file
|
|
152
157
|
function writeOutputFile(filePath, data) {
|
|
153
|
-
const
|
|
158
|
+
const partial = partialPathFor(filePath);
|
|
159
|
+
const existing = node_fs_1.default.lstatSync(filePath, { throwIfNoEntry: false });
|
|
154
160
|
try {
|
|
155
|
-
|
|
161
|
+
// 0600 while half-written; a link at `filePath` is replaced, so only a
|
|
162
|
+
// regular file there passes its mode on to the new file
|
|
163
|
+
node_fs_1.default.writeFileSync(partial, data, { flag: "wx", mode: 0o600 });
|
|
164
|
+
if (existing?.isFile()) {
|
|
165
|
+
node_fs_1.default.chmodSync(partial, existing.mode & 0o777);
|
|
166
|
+
}
|
|
167
|
+
node_fs_1.default.renameSync(partial, filePath);
|
|
156
168
|
}
|
|
157
|
-
|
|
158
|
-
node_fs_1.default.
|
|
169
|
+
catch (error) {
|
|
170
|
+
node_fs_1.default.rmSync(partial, { force: true });
|
|
171
|
+
throw error;
|
|
159
172
|
}
|
|
160
173
|
}
|
|
161
174
|
// a fresh 0700 directory nobody else can plant a symlink in, for files written
|
|
@@ -177,7 +190,7 @@ function moveOutputFile(from, to) {
|
|
|
177
190
|
throw error;
|
|
178
191
|
}
|
|
179
192
|
}
|
|
180
|
-
const partial =
|
|
193
|
+
const partial = partialPathFor(to);
|
|
181
194
|
try {
|
|
182
195
|
node_fs_1.default.copyFileSync(from, partial, node_fs_1.default.constants.COPYFILE_EXCL);
|
|
183
196
|
node_fs_1.default.renameSync(partial, to);
|
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.
|
|
4
|
+
"version": "1.0.15",
|
|
5
5
|
"description": "Mobile MCP",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@clack/prompts": "^0.9.1",
|
|
29
29
|
"@modelcontextprotocol/express": "2.0.2",
|
|
30
|
-
"@modelcontextprotocol/node": "2.
|
|
30
|
+
"@modelcontextprotocol/node": "^2.1.2",
|
|
31
31
|
"@modelcontextprotocol/server": "2.4.0",
|
|
32
32
|
"add-mcp": "^2.6.0",
|
|
33
33
|
"ajv": "^8.18.0",
|