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: get screen density of android devices (#162)

Hsingchien Cheng (工程師 Hiking)468d9e99a577
diff --git a/src/android.ts b/src/android.ts
index 8be2cc7..2fc45fe 100644
--- a/src/android.ts
+++ b/src/android.ts
@@ -111,7 +111,12 @@ export class AndroidRobot implements Robot {
throw new Error("Failed to get screen size");
}
- const scale = 1;
+ const screenDensity = this.adb("shell", "wm", "density")
+ .toString()
+ .split(" ")
+ .pop();
+
+ const scale = screenDensity ? +screenDensity / 160 : 1;
const [width, height] = screenSize.split("x").map(Number);
return { width, height, scale };
}