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.

feat: support adb without ANDROID_HOME env, assume sdk was installed under $HOME/Library

Gil Megidishc65e51e7e6e5
diff --git a/src/android.ts b/src/android.ts
index 9c32ba1..eaa6fd5 100644
--- a/src/android.ts
+++ b/src/android.ts
@@ -1,5 +1,6 @@
import path from "node:path";
import { execFileSync } from "node:child_process";
+import { existsSync } from "node:fs";
import * as xml from "fast-xml-parser";
@@ -28,12 +29,16 @@ interface UiAutomatorXml {
}
const getAdbPath = (): string => {
- let executable = "adb";
if (process.env.ANDROID_HOME) {
- executable = path.join(process.env.ANDROID_HOME, "platform-tools", "adb");
+ return path.join(process.env.ANDROID_HOME, "platform-tools", "adb");
}
- return executable;
+ const defaultAndroidSdk = path.join(process.env.HOME || "", "Library", "Android", "sdk", "platform-tools", "adb");
+ if (existsSync(defaultAndroidSdk)) {
+ return defaultAndroidSdk;
+ }
+
+ return "adb";
};
const BUTTON_MAP: Record<Button, string> = {