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: Add identifier property to UI elements

Tomoya Miwa862df69aa2a2
diff --git a/src/android.ts b/src/android.ts
index 8b3ebc6..90dac32 100644
--- a/src/android.ts
+++ b/src/android.ts
@@ -18,6 +18,7 @@ interface UiAutomatorXmlNode {
hint?: string;
focused?: string;
"content-desc"?: string;
+ "resource-id"?: string;
}
interface UiAutomatorXml {
@@ -171,6 +172,11 @@ export class AndroidRobot implements Robot {
element.focused = true;
}
+ const resourceId = node["resource-id"];
+ if (resourceId !== null && resourceId !== "") {
+ element.identifier = resourceId;
+ }
+
if (element.rect.width > 0 && element.rect.height > 0) {
elements.push(element);
}
diff --git a/src/robot.ts b/src/robot.ts
index 370355e..3ef5198 100644
--- a/src/robot.ts
+++ b/src/robot.ts
@@ -29,6 +29,7 @@ export interface ScreenElement {
text?: string;
name?: string;
value?: string;
+ identifier?: string;
rect: ScreenElementRect;
// currently only on android tv
diff --git a/src/server.ts b/src/server.ts
index 2ec73eb..cae9adb 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -219,6 +219,7 @@ export const createMcpServer = (): McpServer => {
label: element.label,
name: element.name,
value: element.value,
+ identifier: element.identifier,
coordinates: {
x: element.rect.x,
y: element.rect.y,
diff --git a/src/webdriver-agent.ts b/src/webdriver-agent.ts
index 0510faa..262d590 100644
--- a/src/webdriver-agent.ts
+++ b/src/webdriver-agent.ts
@@ -163,12 +163,13 @@ export class WebDriverAgent {
if (acceptedTypes.includes(source.type)) {
if (source.isVisible === "1" && this.isVisible(source.rect)) {
- if (source.label !== null || source.name !== null) {
+ if (source.label !== null || source.name !== null || source.rawIdentifier !== null) {
output.push({
type: source.type,
label: source.label,
name: source.name,
value: source.value,
+ identifier: source.rawIdentifier,
rect: {
x: source.rect.x,
y: source.rect.y,