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: allow adb to fail when listing devices (#35)

Gil Megidish5bd8b0ee17ae
diff --git a/src/android.ts b/src/android.ts
index 407e764..0b64525 100644
--- a/src/android.ts
+++ b/src/android.ts
@@ -240,10 +240,15 @@ export class AndroidRobot implements Robot {
}
export const getConnectedDevices = (): string[] => {
- return execFileSync(getAdbPath(), ["devices"])
- .toString()
- .split("\n")
- .filter(line => !line.startsWith("List of devices attached"))
- .filter(line => line.trim() !== "")
- .map(line => line.split("\t")[0]);
+ try {
+ return execFileSync(getAdbPath(), ["devices"])
+ .toString()
+ .split("\n")
+ .filter(line => !line.startsWith("List of devices attached"))
+ .filter(line => line.trim() !== "")
+ .map(line => line.split("\t")[0]);
+ } catch (error) {
+ console.error("Could not execute adb command, maybe ANDROID_HOME is not set?");
+ return [];
+ }
};