mcpField
A
ADB Friend

ADB Friend

本地服务
github.com/mikepenz开发工具761 天前更新

关于 ADB Friend

ADB Friend 是一个命令行工具,用于通过 ADB 管理 Android 设备,主要面向开发者,也可供其他用户使用。自 1.4.0 版起内置 MCP 服务,可接入 Claude Desktop 等 AI 工具。

主要功能

  1. 01将本地文件同步到 Android 设备并跳过已存在文件
  2. 02配置测试设备,如关闭动画、开启触摸
  3. 03按匹配模式批量卸载应用
  4. 04检测 USB 线缆的连接速度
  5. 05通过 MCP 服务提供设备、应用与文件操作工具

适用场景

  1. 01为自动化测试准备设备和测试数据
  2. 02通过 AI 工具查询已连接设备上安装的应用
  3. 03让 AI 整理设备下载目录或截取屏幕截图

MCP 相关

该项目内置 MCP 服务,通过 adbfriend mcp server 启动,向 MCP 客户端提供设备、应用和文件相关工具。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"adbfriend": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/inspector"
]
}
}
}
启动命令npx -y @modelcontextprotocol/inspector

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npm@modelcontextprotocol/inspector

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

ADB Friend

ADB Friend 是一款小巧的 CLI 工具,可帮助你通过 ADB 管理 Android 设备。 它的大多数功能都是为开发者设计的,但也适用于所有人。

功能

  • 将文件从电脑同步到手机
    • 专为测试数据设计,会跳过设备上已存在的文件
  • 配置设备以进行测试
    • 禁用动画、启用触摸显示等
  • 按模式卸载应用
  • Packages 命令
    • 对所有匹配 glob 的软件包应用沉浸式标志、强制停止应用、清除应用数据和缓存
  • 其他工具
    • adb-speed(帮助识别性能不佳的数据线)
  • Model Context Protocol MCP 服务

安装

可以使用 Homebrew 进行安装。首先,你需要添加自定义 tap:

brew tap mikepenz/tap

接下来,安装 AdbFriend CLI:

brew install mikepenz/tap/adbfriend

你也可以从发布页面下载预构建二进制文件。

用法

ADB Friend 是一款可在终端中使用的命令行工具。

# Get started with the `--help` command, to get information and an overview on the various features offered.
adbfriend --help

MCP 服务

ADB Friend(从版本 1.4.0 起)还提供 Model Context Protocol(MCP)服务,可配置到常见的 AI 工具中,例如 Claude Desktop、GitHub Copilot、RayCast 等。

配置

配置文件的位置和具体内容取决于所使用的工具。以下示例适用于 Claude Desktop。

{
  "mcpServers": {
    "adb-friend": {
      "command": "/opt/homebrew/bin/adbfriend",
      "args": [
        "mcp",
        "server"
      ],
      "env": {
        "ANDROID_HOME": "/Users/mikepenz/Development/android/sdk"
      }
    }
  }
}

重要


如果未提供 ANDROID_HOME,则必须在你的机器上手动启动 adb-server。 否则会引发连接异常。

调试服务

启动服务后,你可以使用 npx @modelcontextprotocol/inspector 进行调试。

# Install and run inspector in your terminal
npx @modelcontextprotocol/inspector

然后启动网站(网址会显示在终端中)。 使用 IntelliJ 或实际命令启动 mcp server。

# Default port is `3001`
adbfriend mcp server --sse true
支持的工具
工具名称描述
check-adb-speed检查指定序列号的 Android 设备的 USB 连接速度。
clear-installed-package清除 Android 设备上指定软件包名称的软件包数据。
set-immersive-full-for-package为 Android 设备上指定的软件包名称设置 immersive-full 标志。
force-stop-process强制停止 Android 设备上指定的软件包名称对应的进程。
uninstall-package卸载 Android 设备上指定的软件包名称。
get-connected-devices获取所有已连接 Android 设备的信息,包括序列号、型号和状态。
get-installed-packages获取 Android 设备上所有已安装软件包的信息。支持仅筛选第三方应用。
list_allowed_directories列出文件系统工具允许访问的目录。
list-files列出 Android 设备上的文件和目录。支持使用 recursive 选项递归列出。
read-file读取 Android 设备上文件的内容。
read_multiple_files一次读取多个 Android 设备上的文件内容(减少大模型调用次数)。
write-file将内容写入 Android 设备上的文件。
create-directory在 Android 设备上创建目录。
delete删除文件或目录。
search-files在允许的目录中搜索匹配不区分大小写的 glob 模式的文件。
move_file将 Android 设备上的文件从源路径移动到目标路径。
copy-file-to-host将二进制文件从 Android 设备复制到主机系统。
capture-screenshot截取 Android 设备的屏幕截图并保存到主机系统。
install-apk从主机系统允许的路径中的文件在 Android 设备上安装 APK。

未来还计划推出更多工具。

示例提示词
uninstall the 'sample' app, but keep its data
force stop the 'sample' app
Do I have a browser installed on the connected emulator?
Organize all files in the Download folder of the connected Android device
 Pull all KotlinConf related files from the Android device to the host

发布

项目使用 shadow 将工具打包为 fat-jar,并进行最低限度的缩减。

./gradlew adbfriend-cli:shadowDistZip

其他

AboutLibraries
为 adbfriend 生成 aboutlibraries.json
./gradlew adbfriend:exportLibraryDefinitions
为 adbfriend-cli 生成 aboutlibraries.json
./gradlew adbfriend-cli:exportLibraryDefinitions
示例提示词截图

Claude Desktop claude-desktop-sample-prompt

Visual Code visual-code-sample-prompt.png

致谢

本项目使用了 Malinskiy 开发的出色 adam 库 与 adb 交互。 CLI 使用了 ajalt 开发的出色 clikt 库进行配置。

许可证
Copyright 2025 Mike Penz

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。