Skip to content

Mobile MCP: let AI agents drive your iOS and Android apps. MCP server for simulators, emulators and real devices. Works with Claude Code, Codex, Cursor and any MCP client.

fix: handle errors in getDeviceType to prevent empty device list (#286)

Andy429ec4f98ac1
diff --git a/src/android.ts b/src/android.ts
index 8378da1..8be2cc7 100644
--- a/src/android.ts
+++ b/src/android.ts
@@ -519,13 +519,17 @@ export class AndroidRobot implements Robot {
export class AndroidDeviceManager {
private getDeviceType(name: string): AndroidDeviceType {
- const device = new AndroidRobot(name);
- const features = device.getSystemFeatures();
- if (features.includes("android.software.leanback") || features.includes("android.hardware.type.television")) {
- return "tv";
+ try {
+ const device = new AndroidRobot(name);
+ const features = device.getSystemFeatures();
+ if (features.includes("android.software.leanback") || features.includes("android.hardware.type.television")) {
+ return "tv";
+ }
+ return "mobile";
+ } catch (error) {
+ // Fallback to mobile if we cannot determine device type
+ return "mobile";
}
-
- return "mobile";
}
private getDeviceVersion(deviceId: string): string {