@mobilenext/mobile-mcp 0.0.62 → 1.0.0
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.md +1 -0
- package/lib/server.js +83 -69
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -467,6 +467,7 @@ Gmail to contacts "team@example.com".
|
|
|
467
467
|
| `MOBILEMCP_AUTH` | Require a Bearer token on the SSE server — every request must then send `Authorization: Bearer <token>`. | `MOBILEMCP_AUTH=my-secret-token` |
|
|
468
468
|
| `MOBILEMCP_DISABLE_TELEMETRY` | Disable anonymous usage telemetry. | `MOBILEMCP_DISABLE_TELEMETRY=1` |
|
|
469
469
|
| `MOBILEMCP_ALLOW_UNSAFE_URLS` | Allow `mobile_open_url` to open non-standard URL schemes (blocked by default). | `MOBILEMCP_ALLOW_UNSAFE_URLS=1` |
|
|
470
|
+
| `MOBILEMCP_LEGACY_ROBOT` | Use the legacy platform-specific robots for Android devices and physical iOS devices. iOS simulators continue to use `mobilecli`. | `MOBILEMCP_LEGACY_ROBOT=1` |
|
|
470
471
|
|
|
471
472
|
### Simulators, Emulators, and Real Devices
|
|
472
473
|
|
package/lib/server.js
CHANGED
|
@@ -93,6 +93,7 @@ const createMcpServer = () => {
|
|
|
93
93
|
Version: (0, exports.getAgentVersion)(),
|
|
94
94
|
NodeVersion: process.version,
|
|
95
95
|
CI: process.env.CI || "0",
|
|
96
|
+
RobotMode: process.env.MOBILEMCP_LEGACY_ROBOT === "1" ? "legacy" : "mobilecli",
|
|
96
97
|
};
|
|
97
98
|
const clientName = getClientName();
|
|
98
99
|
if (clientName !== "unknown") {
|
|
@@ -136,39 +137,43 @@ const createMcpServer = () => {
|
|
|
136
137
|
const getRobotFromDevice = (deviceId) => {
|
|
137
138
|
// from now on, we must have mobilecli working
|
|
138
139
|
ensureMobilecliAvailable();
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
140
|
+
const legacyRobot = process.env.MOBILEMCP_LEGACY_ROBOT === "1";
|
|
141
|
+
if (legacyRobot) {
|
|
142
|
+
// Check if it's an iOS device
|
|
143
|
+
const iosManager = new ios_1.IosManager();
|
|
144
|
+
const iosDevices = iosManager.listDevices();
|
|
145
|
+
const iosDevice = iosDevices.find(d => d.deviceId === deviceId);
|
|
146
|
+
if (iosDevice) {
|
|
147
|
+
posthog("get_robot", { "DevicePlatform": "ios", "DeviceType": "real" }).then();
|
|
148
|
+
return new ios_1.IosRobot(deviceId);
|
|
149
|
+
}
|
|
150
|
+
// Check if it's an Android device
|
|
151
|
+
const androidManager = new android_1.AndroidDeviceManager();
|
|
152
|
+
const androidDevices = androidManager.getConnectedDevices();
|
|
153
|
+
const androidDevice = androidDevices.find(d => d.deviceId === deviceId);
|
|
154
|
+
if (androidDevice) {
|
|
155
|
+
posthog("get_robot", { "DevicePlatform": "android", "DeviceType": androidDevice.deviceType }).then();
|
|
156
|
+
return new android_1.AndroidRobot(deviceId);
|
|
157
|
+
}
|
|
154
158
|
}
|
|
155
|
-
|
|
156
|
-
const response = mobilecli.getDevices({
|
|
159
|
+
const response = mobilecli.getDevices(legacyRobot ? {
|
|
157
160
|
platform: "ios",
|
|
158
161
|
type: "simulator",
|
|
159
162
|
includeOffline: false,
|
|
163
|
+
} : {
|
|
164
|
+
includeOffline: false,
|
|
160
165
|
});
|
|
161
166
|
if (response.status === "ok" && response.data && response.data.devices) {
|
|
162
167
|
for (const device of response.data.devices) {
|
|
163
168
|
if (device.id === deviceId) {
|
|
164
|
-
if (!agentVerifiedSimulators.has(deviceId)) {
|
|
169
|
+
if (device.platform === "ios" && device.type === "simulator" && !agentVerifiedSimulators.has(deviceId)) {
|
|
165
170
|
const agentStatus = mobilecli.agentStatus(deviceId);
|
|
166
171
|
if (agentStatus.status === "fail") {
|
|
167
172
|
mobilecli.agentInstall(deviceId);
|
|
168
173
|
}
|
|
169
174
|
agentVerifiedSimulators.add(deviceId);
|
|
170
175
|
}
|
|
171
|
-
posthog("get_robot", { "DevicePlatform":
|
|
176
|
+
posthog("get_robot", { "DevicePlatform": device.platform, "DeviceType": device.type }).then();
|
|
172
177
|
return new mobile_device_1.MobileDevice(deviceId);
|
|
173
178
|
}
|
|
174
179
|
}
|
|
@@ -178,64 +183,73 @@ const createMcpServer = () => {
|
|
|
178
183
|
tool("mobile_list_available_devices", "List Devices", "List all available devices. This includes both physical mobile devices and mobile simulators and emulators. It returns both Android and iOS devices.", {}, { readOnlyHint: true }, async ({}, telemetry) => {
|
|
179
184
|
// from today onward, we must have mobilecli working
|
|
180
185
|
ensureMobilecliAvailable();
|
|
181
|
-
const iosManager = new ios_1.IosManager();
|
|
182
|
-
const androidManager = new android_1.AndroidDeviceManager();
|
|
183
186
|
const devices = [];
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
devices
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
type: "emulator",
|
|
193
|
-
version: device.version,
|
|
194
|
-
state: "online",
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
// Get iOS physical devices with details
|
|
198
|
-
telemetry.IosRealCount = 0;
|
|
199
|
-
try {
|
|
200
|
-
const iosDevices = iosManager.listDevicesWithDetails();
|
|
201
|
-
telemetry.IosRealCount = iosDevices.length;
|
|
202
|
-
for (const device of iosDevices) {
|
|
187
|
+
const legacyRobot = process.env.MOBILEMCP_LEGACY_ROBOT === "1";
|
|
188
|
+
if (legacyRobot) {
|
|
189
|
+
const iosManager = new ios_1.IosManager();
|
|
190
|
+
const androidManager = new android_1.AndroidDeviceManager();
|
|
191
|
+
// Get Android devices with details
|
|
192
|
+
const androidDevices = androidManager.getConnectedDevicesWithDetails();
|
|
193
|
+
telemetry.AndroidCount = androidDevices.length;
|
|
194
|
+
for (const device of androidDevices) {
|
|
203
195
|
devices.push({
|
|
204
196
|
id: device.deviceId,
|
|
205
|
-
name: device.
|
|
206
|
-
platform: "
|
|
207
|
-
type: "
|
|
197
|
+
name: device.name,
|
|
198
|
+
platform: "android",
|
|
199
|
+
type: "emulator",
|
|
208
200
|
version: device.version,
|
|
209
201
|
state: "online",
|
|
210
202
|
});
|
|
211
203
|
}
|
|
204
|
+
// Get iOS physical devices with details
|
|
205
|
+
telemetry.IosRealCount = 0;
|
|
206
|
+
try {
|
|
207
|
+
const iosDevices = iosManager.listDevicesWithDetails();
|
|
208
|
+
telemetry.IosRealCount = iosDevices.length;
|
|
209
|
+
for (const device of iosDevices) {
|
|
210
|
+
devices.push({
|
|
211
|
+
id: device.deviceId,
|
|
212
|
+
name: device.deviceName,
|
|
213
|
+
platform: "ios",
|
|
214
|
+
type: "real",
|
|
215
|
+
version: device.version,
|
|
216
|
+
state: "online",
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
// If go-ios is not available, silently skip
|
|
222
|
+
}
|
|
223
|
+
// Get iOS simulators from mobilecli, including offline ones so we can
|
|
224
|
+
// report how many are installed vs booted. only booted ones are returned.
|
|
225
|
+
const response = mobilecli.getDevices({
|
|
226
|
+
platform: "ios",
|
|
227
|
+
type: "simulator",
|
|
228
|
+
includeOffline: true,
|
|
229
|
+
});
|
|
230
|
+
telemetry.IosSimInstalledCount = 0;
|
|
231
|
+
telemetry.IosSimCount = 0;
|
|
232
|
+
if (response.status === "ok" && response.data && response.data.devices) {
|
|
233
|
+
const simulators = response.data.devices;
|
|
234
|
+
const booted = simulators.filter(device => device.state === "online");
|
|
235
|
+
telemetry.IosSimInstalledCount = simulators.length;
|
|
236
|
+
telemetry.IosSimCount = booted.length;
|
|
237
|
+
devices.push(...booted);
|
|
238
|
+
}
|
|
212
239
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
const simulators = response.data.devices;
|
|
227
|
-
const booted = simulators.filter(device => device.state === "online");
|
|
228
|
-
telemetry.IosSimInstalledCount = simulators.length;
|
|
229
|
-
telemetry.IosSimCount = booted.length;
|
|
230
|
-
for (const device of booted) {
|
|
231
|
-
devices.push({
|
|
232
|
-
id: device.id,
|
|
233
|
-
name: device.name,
|
|
234
|
-
platform: device.platform,
|
|
235
|
-
type: device.type,
|
|
236
|
-
version: device.version,
|
|
237
|
-
state: "online",
|
|
238
|
-
});
|
|
240
|
+
else {
|
|
241
|
+
const response = mobilecli.getDevices({ includeOffline: true });
|
|
242
|
+
telemetry.AndroidCount = 0;
|
|
243
|
+
telemetry.IosRealCount = 0;
|
|
244
|
+
telemetry.IosSimInstalledCount = 0;
|
|
245
|
+
telemetry.IosSimCount = 0;
|
|
246
|
+
if (response.status === "ok" && response.data && response.data.devices) {
|
|
247
|
+
const availableDevices = response.data.devices.filter(device => device.state === "online");
|
|
248
|
+
telemetry.AndroidCount = availableDevices.filter(device => device.platform === "android").length;
|
|
249
|
+
telemetry.IosRealCount = availableDevices.filter(device => device.platform === "ios" && device.type === "real").length;
|
|
250
|
+
telemetry.IosSimInstalledCount = response.data.devices.filter(device => device.platform === "ios" && device.type === "simulator").length;
|
|
251
|
+
telemetry.IosSimCount = availableDevices.filter(device => device.platform === "ios" && device.type === "simulator").length;
|
|
252
|
+
devices.push(...availableDevices);
|
|
239
253
|
}
|
|
240
254
|
}
|
|
241
255
|
const out = { devices };
|
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": "0.0
|
|
4
|
+
"version": "1.0.0",
|
|
5
5
|
"description": "Mobile MCP",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"commander": "14.0.0",
|
|
30
30
|
"express": "5.1.0",
|
|
31
31
|
"fast-xml-parser": "5.8.0",
|
|
32
|
-
"mobilewright": "0.0.
|
|
32
|
+
"mobilewright": "0.0.52",
|
|
33
33
|
"qs": "^6.15.0",
|
|
34
34
|
"zod": "^4.1.13",
|
|
35
35
|
"zod-to-json-schema": "3.25.0"
|