Android MCP
Android MCP
从任何 AI 代理全面控制 Android — Claude, OpenCode, Windsurf, Cursor 等…… 7 类 MCP 工具 · 90fps 实时查看器 · WiFi ADB · 无需安装手机端应用
快速演示
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 PCRelated MCP server: phone-eye
架构
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 / emulatorsADB 后端(主要) — 适用于任何开启开发者模式的设备。
手机端无需安装任何内容。使用 uiautomator2 + ADB 命令。
配套后端(备选) — 当网络中无法使用 ADB 时,可选的 Flutter 应用。
要求
Python 3.10+
ADB 需在 PATH 中 (
winget install Google.PlatformTools)Android: 开发者模式 + USB 调试(或 WiFi 调试)
安装
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实时查看器 90fps(可选)
winget install Genymobile.scrcpy
python viewer.pyMCP 配置
# 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 filesClaude Desktop 示例 (claude_desktop_config.json):
{
"mcpServers": {
"android-mcp": {
"command": "C:/Python312/python.exe",
"args": ["D:/path/to/android-mcp/server.py"],
"type": "stdio"
}
}
}无需 USB 的 WiFi 连接 (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完整指南 → WIFI_PAIRING.md
7 个 MCP 工具
调用约定: android_xxx(action="...", params={...}, device_id="serial")
device_id 始终可选(使用当前选定的设备)。
android_device — 设备管理
操作 | 参数 | 描述 |
| — | 所有已连接设备(USB、WiFi、模拟器) |
|
| 设置默认设备 |
|
| WiFi ADB 连接 |
| — | 断开当前 WiFi 设备 |
| — | 型号、操作系统、分辨率、密度 |
| — | 设备是否已连接并就绪? |
| — | 配置动画、保持唤醒、ATX 代理 |
android_screen — 截屏与流媒体
操作 | 参数 | 描述 |
| — | PNG 截图(绕过 FLAG_SECURE) → 图像 |
|
| 截取特定区域 → 图像 |
| — |
|
| — | 屏幕是否开启? |
| — | 唤醒屏幕 |
| — | 启动 ADB 流 (~16fps) |
| — | 停止流 |
| — | 最新流帧 → 图像 |
|
| 提取可见文本 (Tesseract) |
|
| 模板匹配 (OpenCV) |
|
| 在 PC 上启动 scrcpy 90fps 窗口 |
android_interact — 触摸、键盘、UI
操作 | 参数 | 描述 |
|
| 点击 |
|
| 双击 |
|
| 长按 |
|
| 滑动 |
|
| 拖拽 |
|
| 双指缩放 |
|
| 多指手势 |
|
| 输入文本 |
| — | 清除活动字段 |
|
| 输入 + 回车 |
|
| 系统按键 (HOME, BACK, ENTER, VOLUME_UP…) |
|
| 按键组合 (keycodes) |
| — | 完整 UI XML 树 (uiautomator2) |
|
| 查找元素并点击 |
|
| 等待元素出现 |
|
| 滚动到元素 |
|
| 断言文本可见 |
android_app — 应用程序
操作 | 参数 | 描述 |
|
| 启动应用 |
|
| 强制停止应用 |
|
| 列出已安装应用 |
|
| 从 PC 安装 APK |
|
| 卸载应用 |
| — | 前台应用包名 |
|
| 打开 URL |
|
| 发送 Android intent |
|
| 打开系统设置 ( |
android_files — 文件
操作 | 参数 | 描述 |
|
| PC → 手机 |
|
| Base64 → 手机 |
|
| 手机 → PC |
|
| 手机 → base64 |
|
| 列出目录内容 |
android_system — 系统与网络
操作 | 参数 | 描述 |
|
| ADB shell 命令 |
|
| Logcat 日志 |
| — | 电池电量和充电状态 |
| — | 读取剪贴板 |
|
| 写入剪贴板 |
|
| 设置音量 |
|
| 屏幕旋转 (0-3) |
|
| WiFi 开/关 |
|
| 蓝牙 开/关 |
|
| 移动数据 开/关 |
| — | 活动通知 |
|
| 模拟 GPS 位置 |
|
| 加速度计、陀螺仪、光线传感器等 |
| — | 可用 WiFi 网络 |
|
| 连接 WiFi |
|
| 读取联系人 |
|
| 发送短信(需在手机上确认) |
android_automation — 批处理与宏
操作 | 参数 | 描述 |
|
| 一次调用运行 N 个操作 |
|
| 开始录制宏 |
|
| 添加操作到宏 |
| — | 保存宏 |
| — | 列出已保存的宏 |
|
| 重放宏 |
|
| 删除宏 |
实时查看器 — 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控制 | 操作 |
左键点击 | 点击 |
拖拽 | 滑动 |
右键点击 | 返回 (BACK) |
滚动 | 滚动 |
| 主页 (HOME) |
| 截图 → PC 剪贴板 |
| 全屏 |
| 旋转 |
测试
# 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项目结构
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示例
# 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"})查看 examples/whatsapp_auto.py 和 examples/agent_loop.py 获取完整用例。
许可证
MIT
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Let Claude, ChatGPT and other agents use your Android phone: see the screen, tap, type, open apps.
Remote MCP server to control your Android phone from AI assistants with per-app permissions.
Let AI agents control Android and iOS devices on Mobilerun Cloud: screen, input, apps, workflows.
Cloud Android devices for AI agents: install an APK, read the screen, tap, type, read logcat.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to control Android phones via MCP and HTTP. Supports screen capture, taps, swipes, text input, and app management.7AGPL 3.0
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to see and operate a real Android phone over adb by fusing live screenshots with UI-tree data, supporting look, tap, swipe, type, and screenshot actions through any MCP client.4MIT
- AlicenseNot gradedqualityBmaintenanceEnables 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.1MIT
- AlicenseNot gradedqualityBmaintenanceEnables 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.6MIT