Android Control MCP Server
Android Control MCP Server
Ein produktionsreifer Model Context Protocol (MCP)-Server, der in Node.js entwickelt wurde und KI-Assistenten (wie Claude Desktop, Cursor und benutzerdefinierte agentische Workflows) ermöglicht, verbundene Android-Geräte zu beobachten, zu analysieren und zu steuern.
🌟 Funktionen
👀 Computer-Use-Beobachtung: Hochauflösende PNG-Bildschirmaufnahme, die direkt als MCP-Bildblöcke zusammen mit Gerätemetadaten zurückgegeben wird.
🔍 UIAutomator-Hierarchie-Parsing: Intelligenter XML-Dump-Parser, der ausführliche Android-UI-Bäume in kompaktes, strukturiertes JSON umwandelt.
🎯 Semantisches Element-Klicken: Klicken Sie Schaltflächen und Steuerelemente anhand ihres sichtbaren Texts, ihrer Barrierefreiheitsbeschreibung oder ihrer Ressourcen-ID, ohne manuelle Pixelberechnungen.
⚡ Schnelle Gesten & Eingabe: Pixelgenaues Tippen, Multi-Koordinaten-Wischen, gerichtetes Scrollen, Hardware-Tasten-Emulation und Shell-escapte Texteingabe.
📱 App-Lebenszyklus-Verwaltung: Starten Sie Anwendungen per Paketnamen und untersuchen Sie die aktuell fokussierte Vordergrund-Aktivität.
🛡️ Sicherheit & Sandboxing: Validierung der Eingabekoordinaten anhand der tatsächlichen Bildschirmgrenzen, streng zugelassene Tastencodes, Argumentbereinigung, Befehls-Timeouts und strikte
stderr-Protokollierung, um die Integrität des stdio-MCP-Streams zu gewährleisten.🔄 Multi-Geräte-Unterstützung: Erkennt automatisch verbundene Geräte oder zielt über
ANDROID_DEVICE_IDauf bestimmte Geräte.
Related MCP server: autoglm-mcp-server
🏗️ Architektur
AI Client (Claude Desktop, Cursor, Agent)
│
│ stdio transport (JSON-RPC)
▼
Node.js MCP Server
│
├── Stderr Structured Logger
├── Zod Schema Validation
│
├── ADB Controller Layer
│ ├── Device Resolver (auto-detect or target serial)
│ ├── Input Engine (tap, swipe, keyevent, text, scroll)
│ ├── Screenshot Manager (exec-out binary stream)
│ └── App Manager (launch, foreground inspection)
│
└── UIAutomator Engine
├── XML Hierarchy Dump & Normalizer
├── Bounds & Center Coordinate Extractor
└── Semantic Element Finder & Click Resolver
│
▼
Android Device / Emulator📋 Voraussetzungen
Node.js:
v20.0.0oder höher (node -v)Android SDK Platform-Tools: ADB (
adb) installiert und im System-PATHverfügbar (oder überADB_PATHkonfiguriert).Android-Gerät oder Emulator:
Physisches Gerät: Per USB verbinden, Entwickleroptionen und USB-Debugging aktivieren.
Emulator: Android Studio AVD, Genymotion oder Headless-Emulator.
Geräteverbindung überprüfen
adb devices -lSie sollten Ihr Gerät als device aufgelistet sehen:
List of devices attached
emulator-5554 device product:sdk_gphone64_arm64 model:sdk_gphone64_arm64🚀 Installation & Schnellstart
# Clone or navigate to the repository
cd c:/Users/Abhishek/Code/mcp
# Install dependencies
npm install
# Run unit tests
npm test
# Start the MCP server
npm start⚙️ Konfiguration
Erstellen Sie eine .env-Datei oder übergeben Sie Umgebungsvariablen:
# Target device ID (serial number). If omitted and 1 device is connected, it auto-selects.
ANDROID_DEVICE_ID=
# Custom path to ADB executable if not in PATH
# Windows: C:\Users\<user>\AppData\Local\Android\Sdk\platform-tools\adb.exe
# macOS: /Users/<user>/Library/Android/sdk/platform-tools/adb
ADB_PATH=adb
# Log level: debug | info | warn | error
LOG_LEVEL=info
# Default ADB timeout in milliseconds
ADB_TIMEOUT_MS=15000🔌 Verbindung zu MCP-Clients
1. Claude-Desktop-Konfiguration
Fügen Sie Folgendes zu Ihrer claude_desktop_config.json hinzu:
Windows:
%APPDATA%\Claude\claude_desktop_config.jsonmacOS:
~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"android-control": {
"command": "node",
"args": ["C:/Users/Abhishek/Code/mcp/src/index.js"],
"env": {
"ANDROID_DEVICE_ID": "",
"ADB_PATH": "adb",
"LOG_LEVEL": "info"
}
}
}
}2. Cursor-/Windsurf-MCP-Konfiguration
In Cursors Features > MCP-Server oder in den Windsurf-Einstellungen:
Name:
android-controlTyp:
commandBefehl:
node C:/Users/Abhishek/Code/mcp/src/index.js
🛠️ MCP-Tools-Referenz
1. android_device_info
Ruft umfassende Geräte-Hardware- und OS-Metadaten ab.
Parameter:
deviceId(optionaler String): Seriennummer des Zielgeräts.
Beispielantwort:
{ "deviceId": "emulator-5554", "model": "Pixel 8", "manufacturer": "Google", "androidVersion": "15", "sdk": 35, "resolution": { "width": 1080, "height": 2400 }, "connectionState": "connected" }
2. android_screenshot
Erfasst den Android-Bildschirm als MCP-Bildinhaltsblock (image/png).
Parameter:
deviceId(optionaler String): Seriennummer des Zielgeräts.
Rückgabe: PNG-Base64-Bilddatenblock + Dimensionsmetadaten.
3. android_ui_dump
Exportiert die aktuelle UIAutomator-Hierarchie des Bildschirms in ein kompaktes, KI-freundliches JSON-Format.
Parameter:
deviceId(optionaler String): Seriennummer des Zielgeräts.
Beispielausgabe:
{ "package": "com.android.settings", "activity": "com.android.settings.Settings", "totalElements": 24, "interactiveElementsCount": 8, "elements": [ { "index": 0, "text": "Network & internet", "resourceId": "android:id/title", "className": "TextView", "clickable": true, "bounds": [196, 340, 1016, 400], "center": [606, 370] } ] }
4. android_find_element
Sucht nach UI-Elementen, die bestimmten Kriterien auf dem aktuellen Bildschirm entsprechen.
Parameter:
text(optionaler String): Sichtbarer Text (exakt oder teilweise).contentDescription(optionaler String): Barrierefreiheits-Label.resourceId(optionaler String): Ressourcen-ID.className(optionaler String): Widget-Klassenname.clickable(optionaler Boolean): Nach Klickbarkeit filtern.exactMatch(optionaler Boolean, Standardfalse): Exakte Zeichenfolgenübereinstimmung.
5. android_click_element
Findet ein Element und klickt in einem einzigen Schritt auf dessen Mittelpunkt.
Parameter:
text(optionaler String): Elementtext.contentDescription(optionaler String): Inhaltsbeschreibung des Elements.resourceId(optionaler String): Ressourcen-ID des Elements.className(optionaler String): Elementklasse.
6. android_tap
Tippt auf exakte (x, y)-Koordinaten mit Validierung der Bildschirmgrenzen.
Parameter:
x(Zahl): X-Koordinate.y(Zahl): Y-Koordinate.
7. android_swipe
Führt eine Zieh-/Wischgeste zwischen zwei Punkten aus.
Parameter:
x1,y1(Zahlen): Startkoordinaten.x2,y2(Zahlen): Endkoordinaten.duration(optionale Zahl, Standard: 300): Dauer in Millisekunden.
8. android_type_text
Gibt Text in das aktuell fokussierte Eingabefeld ein. Behandelt Leerzeichen-Kodierung (%s) und Shell-Zeichen-Escaping.
Parameter:
text(String): Einzugebender Text.
9. android_press_key
Drückt eine Hardware- oder Navigationstaste.
Unterstützte Tasten:
HOME,BACK,ENTER,TAB,ESC,DELETE,SPACE,VOLUME_UP,VOLUME_DOWN,POWER,APP_SWITCH,CAMERAusw.Parameter:
key(String): Tastenname oder numerischer Tastencode.
10. android_scroll
Richtungsbasiertes Scrollen, berechnet anhand der tatsächlichen Bildschirmabmessungen.
Parameter:
direction(String:up|down|left|right)amount(optionale Zahl): Scroll-Distanz in Pixeln.
11. android_launch_app
Startet eine Anwendung anhand ihres Paketnamens.
Parameter:
packageName(String): z. B.com.android.settings,com.google.android.youtube.activity(optionaler String): Name der spezifischen Aktivität.
12. android_current_app
Untersucht das aktuell fokussierte Vordergrundpaket und die Aktivität.
13. android_execute_action (Einheitliches Computer-Use-Tool)
Einheitlicher Aktions-Dispatcher, der alle Aktionen unterstützt: tap, swipe, type, press_key, click_element, scroll, launch_app.
{
"action": "click_element",
"text": "Wi-Fi"
}🤖 Empfohlener KI-Workflow: Beobachten → Analysieren → Handeln → Verifizieren
1. OBSERVE:
AI calls `android_screenshot` and `android_ui_dump`.
2. REASON:
AI inspects visual and UI structure to identify target elements.
3. ACT:
AI calls `android_click_element`, `android_type_text`, or `android_scroll`.
4. VERIFY:
AI captures another screenshot/dump to confirm desired state change.🧪 Testen
Führen Sie die automatisierte Testsuite aus:
npm testDie Tests verwenden Vitest und mocken die ADB-Ausführungsschicht, sodass eine vollständige Einheitenverifizierung ohne physisches Android-Gerät während CI/CD möglich ist.
🔒 Sicherheits-Best Practices
Keine beliebige Shell-Ausführung: Der Server stellt keine rohen
adb shell-Ausführungswerkzeuge bereit.Sichere Prozessaufrufe: Alle Befehle verwenden
child_process.execFilemit expliziten Argumentarrays, um Shell-Injection zu verhindern.Eingabebereinigung: Paketnamen, Tastencodes und Koordinatenparameter werden streng über Zod-Schemas und Grenzwertprüfungen validiert.
Isolierte Stderr-Protokollierung: Alle Protokolle werden ausschließlich an
stderrgeleitet, um die strikte JSON-RPC-Protokollkonformität aufstdoutzu gewährleisten.
📄 Lizenz
MIT
Available Tools
13 toolsandroid_click_elementB
Find and click a UI element on the current Android screen by its visible text, content description, or resource ID. Computes the center of the element and executes a precise tap.
Inputs: text, deviceId, className, exactMatch, +2 more.
android_current_appA
Get the package name and activity of the currently focused foreground Android application.
Inputs: deviceId.
android_device_infoA
Get detailed information about the connected Android device, including device ID, model, manufacturer, Android OS version, SDK level, and screen resolution.
Inputs: deviceId.
android_execute_actionC
Execute a high-level Android action in a single tool call. Supports tap, swipe, type, press_key, click_element, scroll, and launch_app.
Inputs: action (required), x, y, x1, +13 more.
android_find_elementA
Search for UI elements on the current Android screen by visible text, content description, resource ID, or class name. Returns matching elements with their computed center tap coordinates.
Inputs: text, deviceId, className, clickable, +3 more.
android_launch_appB
Launch an Android application by its package name (e.g. "com.android.settings", "com.google.android.youtube", "com.android.chrome").
Inputs: packageName (required), activity, deviceId.
android_press_keyC
Press an Android hardware or navigation key. Supported keys include: HOME, BACK, CALL, ENDCALL, VOLUME_UP, VOLUME_DOWN, POWER, CAMERA, CLEAR, COMMA, PERIOD, TAB, SPACE, ENTER, DELETE, etc.
Inputs: key (required), deviceId.
android_screenshotA
Capture the current screen of the Android device as a PNG image for visual inspection and AI computer-use reasoning.
Inputs: deviceId.
android_scrollB
Scroll the screen in a specified direction (up, down, left, right).
Inputs: direction (required), amount, deviceId.
android_swipeA
Perform a swipe / drag gesture between two points (x1, y1) and (x2, y2) with a configurable duration.
Inputs: x1 (required), x2 (required), y1 (required), y2 (required), +2 more.
android_tapB
Tap at specific (x, y) pixel coordinates on the Android device screen.
Inputs: x (required), y (required), deviceId.
android_type_textA
Type text into the currently focused Android input field. Handles escaping for spaces and special characters.
Inputs: text (required), deviceId.
android_ui_dumpA
Dump the current Android screen UI hierarchy using UIAutomator. Returns a structured, compact list of visible and interactive UI elements with their text, resource IDs, and screen bounds.
Inputs: deviceId.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 13 tools
Most tools have clearly distinct purposes, but android_tap, android_click_element, and android_execute_action overlap in interaction, differing only by abstraction level (raw coordinates, element-based, and high-level bundling). Descriptions help disambiguate these, so the overlap is minor.
All tools share the 'android_' prefix, which is good, but the naming pattern is inconsistent: some are bare nouns (screenshot, scroll), some are verb phrases (type_text, launch_app), and some are noun phrases (current_app, device_info). This mix of conventions is still readable but not fully predictable.
With 13 tools, the server is well-scoped for a mobile automation domain, offering both low-level gestures and high-level actions without redundancy. This count is appropriate and each tool earns its place.
The tool surface covers core UI automation: screen capture, interaction (tap, swipe, type, press, scroll), element discovery (ui_dump, find_element, click_element), and app control (launch_app, current_app). Missing advanced gestures like pinch or long-press, but these are not essential for typical agent tasks.
Maintenance
Related MCP Connectors
Let Claude, ChatGPT and other agents use your Android phone: see the screen, tap, type, open apps.
Cloud Android devices for AI agents: install an APK, read the screen, tap, type, read logcat.
Give your AI agent a real cloud Android phone: push APKs, drive it, get screenshots and logs.
Cloud Android phones for AI agents: create a phone, read the screen, tap, type, install APKs, park.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables AI assistants to interact with Android devices and emulators via ADB, providing tools for screenshots, UI inspection, touch and text input, app management, and device control.42143 npm23MIT
- AlicenseAqualityDmaintenanceEnables AI models to control Android devices via ADB through natural language commands, supporting screen analysis and automated actions.357 npmMIT
- FlicenseBqualityDmaintenanceEnables AI agents to control Android devices via ADB, supporting gestures, input, screenshots, UI analysis, and app management.191-
- AlicenseAqualityCmaintenanceEnables AI agents to control, inspect, and automate Android devices, Waydroid containers, and AVD emulators over ADB. Provides tools for screenshots, UI-hierarchy text-based tapping, gestures, key presses, text input, app management, and raw shell commands.12MIT