CA

cursortouch/android-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

909 stars 127 forks 质量 76 趋势 43MIT

MCP服务器用于与安卓设备交互。

概览

是一款轻量级开源工具,连接了AI代理与Android设备。作为MCP服务器运行,它使LLM代理能够执行现实世界的任务,而无需依赖传统的计算机视觉流水线或预编程脚本。 https://github.com/user-attachments/assets/cf9a5e4e-b69f-46d4-8487-0f61a7a86d67 - 通过 ADB 和 Android 辅助 API 与 UI 元素交互:启动应用、点击、滑动、输入文本并阅读视图层级结构。 - 支持任何语言模型,无需微调的 CV 模型或 OCR 流水线。 - 预建工具,包括手势、按键操作、捕获、设备状态、shell 命令执行。 - 动作间的典型延迟(例如两次分流)会根据设备规格和负载而变化。 - Python 3.13 - ADB(Android 调试桥)- Android 10+(模拟器/Android设备) 在运行服务器之前,请确保你的安卓设备已连接并被ADB识别:

概述(AI 翻译)

Android-MCP 的洁净室重实现:一个 MCP 该服务器允许AI代理通过ADB操作Android设备。

只需要adb。设备上没有安装任何东西,也没有依赖于 uiAutomator2。

跑

需要 Python 3.13 和 adb(Android 平台工具)。

服务器在stdio上使用MCP。客户端配置中:

设备在第一次工具调用时就已连接,因此无论是否有连接,服务器都会启动 还没准备好。

选择装置

没有选项时,它会用第一个物理设备,或者在没有模拟器时使用。

选项 环境 含义
--device SERIAL ANDROID_MCP_DEVICE 网络上的设备序列号,或称host:port
--connection auto|usb|wifi(别名 --transport) ANDROID_MCP_CONNECTION 当没有装置命名时如何选择
--wifi [HOST] ANDROID_MCP_HOST 通过Wi-Fi的ADB;HOST 或 HOST:PORT,默认端口5555
--usb [SERIAL] 通过USB进行ADB,可选特定序列号

选择权胜过环境。其他变量:

  • ANDROID_MCP_ADB_PATH 命名 adb 二元进制。否则,adb 在 PATH 中查找,然后在

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

android-mcp-beta

Clean-room reimplementation of Android-MCP: an MCP server that lets an AI agent operate an Android device over ADB.

It needs only adb. Nothing is installed on the device, and there is no dependency on uiautomator2.

Run

Requires Python 3.13 and adb (Android platform-tools).

uv run android-mcp-beta

The server speaks MCP on stdio. In a client’s config:

{
  "mcpServers": {
    "android-mcp-beta": {
      "command": "uv",
      "args": ["--directory", "D:/Projects/android-mcp-beta", "run", "android-mcp-beta"]
    }
  }
}

The device is connected on the first tool call, so the server starts whether or not one is attached yet.

Choosing the device

With no options it uses the first physical device, or an emulator when there is none.

Option Environment Meaning
--device SERIAL ANDROID_MCP_DEVICE A serial, or host:port for a device on the network
--connection auto|usb|wifi (alias --transport) ANDROID_MCP_CONNECTION How to pick when no device is named
--wifi [HOST] ANDROID_MCP_HOST ADB over Wi-Fi; HOST or HOST:PORT, port 5555 by default
--usb [SERIAL] ADB over USB, optionally a specific serial

Options win over the environment. Other variables:

  • ANDROID_MCP_ADB_PATH names the adb binary. Otherwise adb is looked for on PATH, then in ANDROID_HOME, ANDROID_SDK_ROOT and the default Android Studio SDK folders.
  • SCREENSHOT_QUANTIZED=true reduces screenshots to 256 colours, which makes them smaller.

Tools

Tool Does
ListDevices, ConnectDevice, Device List, choose, or disconnect the device
Snapshot The interactive elements, each with a label and tap coordinates. use_vision adds a screenshot with the labels drawn on it; use_annotation=false leaves it clean
Click, LongClick, Swipe, Drag Touch input by coordinates
ClickBySelector Tap an element found by text, resourceId, className or description (exact match; resourceId may be the part after the slash), with index for the nth match
Type Type into a field. x and y tap it first; clear empties it first. Other scripts and emoji need the optional ADBKeyboard app (below)
Press A button: back, home, recent, volume up, enter, and so on
Notification Pull down the notification shade
Wait, WaitForElement Pause, or wait for an element to appear

Typing other scripts (optional)

Type uses adb shell input text, so on its own it types printable ASCII and the accented Latin letters Android can compose (é ñ ü ÿ and 107 others, not ç ß å ø). A newline presses Enter and a tab presses Tab. For anything else (CJK, Cyrillic, Arabic, emoji, ç), install the ADBKeyboard app on the device once:

adb install keyboardservice-debug.apk
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "android-mcp-beta": { "command": "uv", "args": ["--directory", "D:/Projects/android-mcp-beta", "run", "android-mcp-beta"] } } }