@mobilenext/mobile-mcp 1.0.4 → 1.0.5
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 +1 -1
- package/README.zh-CN.md +1 -1
- package/lib/index.js +7 -7
- package/lib/server.js +39 -6
- package/package.json +7 -4
package/README.ja.md
CHANGED
|
@@ -304,7 +304,7 @@ gemini mcp add mobile-mcp npx -y @mobilenext/mobile-mcp@latest
|
|
|
304
304
|
|
|
305
305
|
#### ボタンをクリックしてインストール:
|
|
306
306
|
|
|
307
|
-
[](https://goose-docs.ai/extension?cmd=npx&arg=-y&arg=%40mobilenext%2Fmobile-mcp%40latest&id=mobile-mcp&name=Mobile%20MCP&description=Mobile%20automation%20and%20development%20for%20iOS%2C%20Android%2C%20simulators%2C%20emulators%2C%20and%20real%20devices)
|
|
308
308
|
|
|
309
309
|
#### または手動でインストール:
|
|
310
310
|
|
package/README.md
CHANGED
|
@@ -304,7 +304,7 @@ gemini mcp add mobile-mcp npx -y @mobilenext/mobile-mcp@latest
|
|
|
304
304
|
|
|
305
305
|
#### Click the button to install:
|
|
306
306
|
|
|
307
|
-
[](https://goose-docs.ai/extension?cmd=npx&arg=-y&arg=%40mobilenext%2Fmobile-mcp%40latest&id=mobile-mcp&name=Mobile%20MCP&description=Mobile%20automation%20and%20development%20for%20iOS%2C%20Android%2C%20simulators%2C%20emulators%2C%20and%20real%20devices)
|
|
308
308
|
|
|
309
309
|
#### Or install manually:
|
|
310
310
|
|
package/README.zh-CN.md
CHANGED
|
@@ -304,7 +304,7 @@ gemini mcp add mobile-mcp npx -y @mobilenext/mobile-mcp@latest
|
|
|
304
304
|
|
|
305
305
|
#### 点击按钮安装:
|
|
306
306
|
|
|
307
|
-
[](https://goose-docs.ai/extension?cmd=npx&arg=-y&arg=%40mobilenext%2Fmobile-mcp%40latest&id=mobile-mcp&name=Mobile%20MCP&description=Mobile%20automation%20and%20development%20for%20iOS%2C%20Android%2C%20simulators%2C%20emulators%2C%20and%20real%20devices)
|
|
308
308
|
|
|
309
309
|
#### 或手动安装:
|
|
310
310
|
|
package/lib/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
const express_1 = require("@modelcontextprotocol/express");
|
|
5
|
+
const stdio_1 = require("@modelcontextprotocol/server/stdio");
|
|
6
|
+
const node_1 = require("@modelcontextprotocol/node");
|
|
7
7
|
const server_1 = require("./server");
|
|
8
8
|
const logger_1 = require("./logger");
|
|
9
9
|
const commander_1 = require("commander");
|
|
10
10
|
const startHttpServer = async (host, port) => {
|
|
11
11
|
// createMcpExpressApp applies express.json() and Host-header DNS rebinding
|
|
12
12
|
// protection automatically when binding to localhost / 127.0.0.1 / ::1.
|
|
13
|
-
const app = (0,
|
|
13
|
+
const app = (0, express_1.createMcpExpressApp)({ host });
|
|
14
14
|
// Migration hint for clients still pointing at the removed SSE transport.
|
|
15
15
|
// Registered before auth so unauthenticated clients see the reason, not a 401.
|
|
16
16
|
app.all("/sse", (_req, res) => {
|
|
@@ -41,7 +41,7 @@ const startHttpServer = async (host, port) => {
|
|
|
41
41
|
// (Smithery / horizontal-host friendly; no session affinity).
|
|
42
42
|
const server = (0, server_1.createMcpServer)();
|
|
43
43
|
try {
|
|
44
|
-
const transport = new
|
|
44
|
+
const transport = new node_1.NodeStreamableHTTPServerTransport({
|
|
45
45
|
sessionIdGenerator: undefined,
|
|
46
46
|
});
|
|
47
47
|
// Register cleanup first: the response can close before handleRequest resolves.
|
|
@@ -87,7 +87,7 @@ const startHttpServer = async (host, port) => {
|
|
|
87
87
|
};
|
|
88
88
|
const startStdioServer = async () => {
|
|
89
89
|
try {
|
|
90
|
-
const transport = new
|
|
90
|
+
const transport = new stdio_1.StdioServerTransport();
|
|
91
91
|
const server = (0, server_1.createMcpServer)();
|
|
92
92
|
await server.connect(transport);
|
|
93
93
|
// Exit cleanly on termination signals so node flushes pending work
|
|
@@ -99,7 +99,7 @@ const startStdioServer = async () => {
|
|
|
99
99
|
};
|
|
100
100
|
process.on("SIGINT", shutdown);
|
|
101
101
|
process.on("SIGTERM", shutdown);
|
|
102
|
-
(0, logger_1.error)(
|
|
102
|
+
(0, logger_1.error)(`mobile-mcp ${(0, server_1.getAgentVersion)()} (mcp sdk ${(0, server_1.getSdkVersion)()}) server running on stdio`);
|
|
103
103
|
}
|
|
104
104
|
catch (err) {
|
|
105
105
|
console.error("Fatal error in main():", err);
|
package/lib/server.js
CHANGED
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createMcpServer = exports.getAgentVersion = void 0;
|
|
7
|
-
const
|
|
6
|
+
exports.createMcpServer = exports.getSdkVersion = exports.getAgentVersion = void 0;
|
|
7
|
+
const server_1 = require("@modelcontextprotocol/server");
|
|
8
8
|
const zod_1 = require("zod");
|
|
9
9
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
10
10
|
const node_os_1 = __importDefault(require("node:os"));
|
|
@@ -36,10 +36,43 @@ const getAgentVersion = () => {
|
|
|
36
36
|
return json.version;
|
|
37
37
|
};
|
|
38
38
|
exports.getAgentVersion = getAgentVersion;
|
|
39
|
+
const getSdkVersion = () => {
|
|
40
|
+
try {
|
|
41
|
+
// the sdk doesn't export its package.json, so resolve the installed
|
|
42
|
+
// package directory and read it from disk.
|
|
43
|
+
const entry = require.resolve("@modelcontextprotocol/server");
|
|
44
|
+
const packageRoot = entry.slice(0, entry.lastIndexOf(`${node_path_1.default.sep}dist${node_path_1.default.sep}`));
|
|
45
|
+
return JSON.parse(node_fs_1.default.readFileSync(node_path_1.default.join(packageRoot, "package.json"), "utf8")).version;
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
return "unknown version";
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
exports.getSdkVersion = getSdkVersion;
|
|
52
|
+
const SERVER_INSTRUCTIONS = `Drive a real or simulated iOS/Android device.
|
|
53
|
+
|
|
54
|
+
Start with mobile_list_available_devices and pass the chosen device id to every
|
|
55
|
+
later call - there is no implicit "current device". Use a remote device only
|
|
56
|
+
when local ones do not fit or when requested by the user. Remote devices cost
|
|
57
|
+
money and take time to allocate and release. Release when done using, so the
|
|
58
|
+
remote device cleans and returns to pool.
|
|
59
|
+
|
|
60
|
+
Read the screen with mobile_list_elements_on_screen, not screenshots: it returns
|
|
61
|
+
refs, coordinates and labels, and tapping by ref survives layout differences
|
|
62
|
+
between devices. Fall back to mobile_take_screenshot only for elements missing
|
|
63
|
+
from the hierarchy, or to judge visual appearance.
|
|
64
|
+
|
|
65
|
+
Each call is a device round-trip. Group known sequences (tap, type, tap) into
|
|
66
|
+
mobile_batch_commands instead of issuing them one at a time.
|
|
67
|
+
|
|
68
|
+
Prefer mobile_open_url or mobile_launch_app over navigating through the UI to
|
|
69
|
+
reach a screen.`;
|
|
39
70
|
const createMcpServer = () => {
|
|
40
|
-
const server = new
|
|
71
|
+
const server = new server_1.McpServer({
|
|
41
72
|
name: "mobile-mcp",
|
|
42
73
|
version: (0, exports.getAgentVersion)(),
|
|
74
|
+
}, {
|
|
75
|
+
instructions: SERVER_INSTRUCTIONS,
|
|
43
76
|
});
|
|
44
77
|
const getClientName = () => {
|
|
45
78
|
try {
|
|
@@ -58,7 +91,7 @@ const createMcpServer = () => {
|
|
|
58
91
|
server.registerTool(name, {
|
|
59
92
|
title,
|
|
60
93
|
description,
|
|
61
|
-
inputSchema: paramsSchema,
|
|
94
|
+
inputSchema: zod_1.z.object(paramsSchema),
|
|
62
95
|
annotations,
|
|
63
96
|
}, (async (args, _extra) => {
|
|
64
97
|
scarf();
|
|
@@ -564,11 +597,11 @@ const createMcpServer = () => {
|
|
|
564
597
|
server.registerTool("mobile_take_screenshot", {
|
|
565
598
|
title: "Take Screenshot",
|
|
566
599
|
description: "Take a screenshot of the mobile device. Use this to understand what's on screen, if you need to press an element that is available through view hierarchy then you must list elements on screen instead. The screenshot is usually smaller than the screen, so when the device reports its screen size the result also states how to convert positions in the screenshot into screen coordinates before tapping. Do not cache this result.",
|
|
567
|
-
inputSchema: {
|
|
600
|
+
inputSchema: zod_1.z.object({
|
|
568
601
|
device: zod_1.z.string().describe("The device identifier to use. Use mobile_list_available_devices to find which devices are available to you."),
|
|
569
602
|
maxSize: zod_1.z.number().int().positive().optional().describe(`Maximum width/height in pixels, keeping aspect ratio. Defaults to ${DEFAULT_SCREENSHOT_MAX_SIZE}.`),
|
|
570
603
|
scale: zod_1.z.number().gt(0).max(1).optional().describe("Scale factor (0.0-1.0). Ignored if maxSize is provided."),
|
|
571
|
-
},
|
|
604
|
+
}),
|
|
572
605
|
annotations: {
|
|
573
606
|
readOnlyHint: true,
|
|
574
607
|
openWorldHint: true,
|
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.5",
|
|
5
5
|
"description": "Mobile MCP",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -25,19 +25,22 @@
|
|
|
25
25
|
"lib"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@modelcontextprotocol/
|
|
28
|
+
"@modelcontextprotocol/express": "2.0.0",
|
|
29
|
+
"@modelcontextprotocol/node": "2.0.0",
|
|
30
|
+
"@modelcontextprotocol/server": "2.0.0",
|
|
29
31
|
"ajv": "^8.18.0",
|
|
30
32
|
"commander": "14.0.0",
|
|
31
33
|
"express": "5.1.0",
|
|
32
34
|
"fast-xml-parser": "5.8.0",
|
|
33
|
-
"mobilewright": "0.0.
|
|
35
|
+
"mobilewright": "0.0.60",
|
|
34
36
|
"qs": "^6.15.0",
|
|
35
|
-
"zod": "^4.
|
|
37
|
+
"zod": "^4.2.0",
|
|
36
38
|
"zod-to-json-schema": "3.25.0"
|
|
37
39
|
},
|
|
38
40
|
"devDependencies": {
|
|
39
41
|
"@eslint/eslintrc": "^3.2.0",
|
|
40
42
|
"@eslint/js": "^9.19.0",
|
|
43
|
+
"@modelcontextprotocol/client": "2.0.0",
|
|
41
44
|
"@playwright/test": "^1.49.0",
|
|
42
45
|
"@stylistic/eslint-plugin": "^3.0.1",
|
|
43
46
|
"@types/commander": "^2.12.0",
|