Skip to main content
Glama
Android MCP

Android MCP

by Steph-ux

Android MCP

Vollständige Android-Steuerung von jedem KI-Agenten — Claude, OpenCode, Windsurf, Cursor… 7 kategorische MCP-Tools · 90fps Live-Viewer · WiFi ADB · keine App-Installation erforderlich


Kurze Demo

android_screen(action="screenshot")                          # PNG capture
android_screen(action="ocr")                                 # visible text
android_interact(action="tap", params={"x": 540, "y": 960}) # tap
android_interact(action="find", params={"text": "Send"})     # find + tap
android_system(action="battery")                             # battery info
android_screen(action="viewer")                              # 90fps interactive window on PC

Related MCP server: phone-eye

Architektur

AI Agent (Claude / OpenCode / Windsurf / Cursor…)
        ↓  MCP Protocol (stdio)
    server.py          ← 7 categorical tools
        ↓
    device_manager.py  ← device selection, multi-device
        ↓
    backends/
        ├── adb_backend.py       ← PRIMARY  : uiautomator2 + direct ADB
        └── companion_backend.py ← FALLBACK : Flutter app WebSocket
        ↓
    N Android phones / emulators

ADB-Backend (primär) — funktioniert auf jedem Gerät mit aktiviertem Entwicklermodus. Nichts auf dem Telefon zu installieren. Verwendet uiautomator2 + ADB-Befehle.

Companion-Backend (Fallback) — optionale Flutter-App, wenn ADB im Netzwerk nicht verfügbar ist.


Anforderungen

  • Python 3.10+

  • ADB im PATH (winget install Google.PlatformTools)

  • Android: Entwicklermodus + USB-Debugging (oder WiFi-Debugging)


Installation

git clone https://github.com/Steph-ux/android-mcp
cd android-mcp
pip install -r requirements.txt

# Initialize uiautomator2 (once per device)
python -m uiautomator2 init

Live-Viewer 90fps (optional)

winget install Genymobile.scrcpy
python viewer.py

MCP-Konfiguration

# Generate the correct JSON for your AI client
python mcp_config.py --client claude     # Claude Desktop
python mcp_config.py --client opencode  # OpenCode
python mcp_config.py --client windsurf  # Windsurf
python mcp_config.py --client cursor    # Cursor
python mcp_config.py --write            # write directly to config files

Beispiel für Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "android-mcp": {
      "command": "C:/Python312/python.exe",
      "args": ["D:/path/to/android-mcp/server.py"],
      "type": "stdio"
    }
  }
}

WiFi-Verbindung ohne USB (Android 11+)

# On the phone: Settings → Developer options → Wireless debugging → Pair device
adb pair 192.168.1.42:38765    # enter the code shown on the phone
adb connect 192.168.1.42:5555

Vollständige Anleitung → WIFI_PAIRING.md


Die 7 MCP-Tools

Aufrufkonvention: android_xxx(action="...", params={...}, device_id="serial") device_id ist immer optional (verwendet das aktuell ausgewählte Gerät).


android_device — Geräteverwaltung

Aktion

Parameter

Beschreibung

list

—

Alle verbundenen Geräte (USB, WiFi, Emulatoren)

select

serial

Standardgerät festlegen

connect

host, port

WiFi ADB-Verbindung

disconnect

—

Aktuelles WiFi-Gerät trennen

info

—

Modell, OS, Auflösung, Dichte

status

—

Ist das Gerät verbunden und bereit?

setup

—

Animationen, Wachbleiben, ATX-Agent konfigurieren


android_screen — Aufnahme & Stream

Aktion

Parameter

Beschreibung

screenshot

—

PNG-Aufnahme (umgeht FLAG_SECURE) → Bild

region

x y width height

Bestimmten Bereich aufnehmen → Bild

size

—

{width, height}

is_on

—

Ist der Bildschirm an?

wake

—

Bildschirm aufwecken

start_stream

—

ADB-Stream starten (~16fps)

stop_stream

—

Stream stoppen

live_frame

—

Aktueller Stream-Frame → Bild

ocr

lang

Sichtbaren Text extrahieren (Tesseract)

find_image

template_b64 threshold

Template-Matching (OpenCV)

viewer

fps bitrate no_control

scrcpy 90fps Fenster auf PC starten


android_interact — Touch, Tastatur, UI

Aktion

Parameter

Beschreibung

tap

x y

Tippen

double_tap

x y

Doppeltippen

long_press

x y duration_ms

Langes Drücken

swipe

x1 y1 x2 y2 duration_ms

Wischen

drag

x1 y1 x2 y2 duration_ms

Ziehen & Ablegen

pinch

x y scale duration_ms

Zoomen (Pinch)

multi_touch

points

Multi-Finger-Gesten

type

text

Text eingeben

clear

—

Aktives Feld leeren

submit

text

Eingeben + Enter

key

key

Systemtaste (HOME, BACK, ENTER, VOLUME_UP…)

combo

keys

Tastenkombination (Keycodes)

hierarchy

—

Vollständiger UI-XML-Baum (uiautomator2)

find

text partial_match

Element finden und darauf tippen

wait

text timeout partial_match

Auf Element warten

scroll

text direction max_swipes

Zu Element scrollen

assert

text partial_match

Sicherstellen, dass Text sichtbar ist


android_app — Anwendungen

Aktion

Parameter

Beschreibung

launch

package

App starten

close

package

App zwangsweise beenden

list

include_system

Installierte Apps auflisten

install

apk_path

APK vom PC installieren

uninstall

package

App deinstallieren

current

—

Vordergrund-App-Paket

url

url

URL öffnen

intent

action uri package extras

Android-Intent senden

settings

section

Systemeinstellungen öffnen (main wifi bluetooth display…)


android_files — Dateien

Aktion

Parameter

Beschreibung

push

local_path remote_path

PC → Telefon

push_b64

remote_path data

Base64 → Telefon

pull

remote_path local_path

Telefon → PC

pull_b64

remote_path

Telefon → Base64

list

directory

Verzeichnisinhalt auflisten


android_system — System & Netzwerk

Aktion

Parameter

Beschreibung

shell

command

ADB-Shell-Befehl

logs

lines package

Logcat

battery

—

Akkustand und Ladestatus

clipboard_get

—

Zwischenablage lesen

clipboard_set

text

In Zwischenablage schreiben

volume

level stream

Lautstärke einstellen

rotation

rotation

Bildschirmdrehung (0-3)

wifi

enabled

WiFi an/aus

bluetooth

enabled

Bluetooth an/aus

mobile_data

enabled

Mobile Daten an/aus

notifications

—

Aktive Benachrichtigungen

gps

lat lng

GPS-Standort simulieren

sensors

sensor

Beschleunigungsmesser, Gyroskop, Licht…

wifi_list

—

Verfügbare WiFi-Netzwerke

wifi_connect

ssid password

Mit WiFi verbinden

contacts

search limit

Kontakte lesen

sms

to message

SMS senden (erfordert Bestätigung auf dem Telefon)


android_automation — Batch & Makros

Aktion

Parameter

Beschreibung

batch

actions stop_on_error

N Aktionen in einem Aufruf ausführen

macro_start

name

Makro-Aufnahme starten

macro_record

action …params

Aktion zum Makro hinzufügen

macro_stop

—

Makro speichern

macro_list

—

Gespeicherte Makros auflisten

macro_replay

name delay_ms

Makro wiedergeben

macro_delete

name

Makro löschen


Live-Viewer — scrcpy 90fps

python viewer.py                  # auto-detect device, 90fps, interactive
python viewer.py --fps 60         # 60fps
python viewer.py --record         # record to .mp4
python viewer.py --record out.mp4 # named output file
python viewer.py --multi          # one viewer per connected device
python viewer.py --no-control     # read-only mode

Steuerung

Aktion

Linksklick

Tippen

Ziehen

Wischen

Rechtsklick

ZURÜCK

Scrollen

Scrollen

Alt+H

HOME

Alt+S

Screenshot → PC-Zwischenablage

Alt+F

Vollbild

Alt+R

Drehung


Tests

# Unit tests (no device required)
pytest tests/test_server_unit.py -v      # 94 tests

# Integration tests (ADB device required)
pytest tests/test_integration.py -v

Projektstruktur

android-mcp/
├── server.py              # MCP server — 7 tools
├── viewer.py              # scrcpy 90fps interactive viewer
├── mcp_config.py          # JSON config generator
├── device_manager.py      # Multi-device management
├── relay.py               # ⚠️ LEGACY — companion fallback only
├── requirements.txt
├── pyproject.toml
├── WIFI_PAIRING.md
├── backends/
│   ├── adb_backend.py     # Primary backend (uiautomator2 + ADB)
│   └── companion_backend.py  # Fallback backend (Flutter app)
├── examples/
│   ├── agent_loop.py      # Autonomous automation loop
│   └── whatsapp_auto.py   # WhatsApp automation example
└── tests/
    ├── conftest.py
    ├── test_server_unit.py   # 94 unit tests
    └── test_integration.py   # Real device tests

Beispiele

# WhatsApp — send a message
await android_app("launch", {"package": "com.whatsapp"})
await android_interact("find", {"text": "Alice"})
await android_interact("type", {"text": "Hello!"})
await android_interact("key",  {"key": "ENTER"})

# Batch in a single call
await android_automation("batch", {"actions": [
    {"action": "key",  "key": "HOME"},
    {"action": "tap",  "x": 540, "y": 200},
    {"action": "type", "text": "search query"},
    {"action": "key",  "key": "ENTER"},
]})

# Macro: record + replay
await android_automation("macro_start",  {"name": "login"})
await android_automation("macro_record", {"action": "tap",  "x": 540, "y": 400})
await android_automation("macro_record", {"action": "type", "text": "password"})
await android_automation("macro_stop")
await android_automation("macro_replay", {"name": "login"})

Siehe examples/whatsapp_auto.py und examples/agent_loop.py für vollständige Anwendungsfälle.


Lizenz

MIT

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to remotely control a real Android phone over MCP with no ADB, root, or emulator, by connecting a broker server to a sideloaded APK. Exposes tools to list devices, capture screenshots, read the UI tree, open links and deep links, and perform taps, swipes, typing, and global navigation actions.
      1
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables MCP-compatible AI agents to perceive and control an Android phone through tools for screenshots, visible text and coordinates, app/screen queries, taps, swipes, text input, key events, app launching, and interrupt/resume, closing the perception-action loop.
      6
      MIT