DroidMind

DroidMind

一个模型上下文协议(MCP)服务器,它使 AI 助手能够控制和交互 Android 设备,从而可以通过自然语言命令实现设备管理、应用调试、系统分析和 UI 自动化。

Category
访问服务器

Tools

list_packages

List installed packages on the device. Args: serial: Device serial number include_system_apps: Whether to include system apps in the list Returns: Formatted list of installed packages

device_properties

Get detailed properties of a specific device. Args: serial: Device serial number Returns: Formatted device properties as text

install_app

Install an APK on the device. Args: serial: Device serial number apk_path: Path to the APK file (local to the server) reinstall: Whether to reinstall if app exists grant_permissions: Whether to grant all requested permissions Returns: Installation result message

uninstall_app

Uninstall an app from the device. Args: serial: Device serial number package: Package name to uninstall keep_data: Whether to keep app data and cache directories Returns: Uninstallation result message

start_app

Start an app on the device. Args: serial: Device serial number package: Package name to start activity: Optional activity name to start (if empty, launches the default activity) Returns: Result message

stop_app

Force stop an app on the device. Args: serial: Device serial number package: Package name to stop Returns: Result message

clear_app_data

Clear app data and cache for the specified package. Args: serial: Device serial number package: Package name to clear data for Returns: Result message

device_logcat

Get recent logcat output from a device. Args: serial: Device serial number lines: Number of recent lines to fetch (default: 1000, max recommended: 20000) Higher values may impact performance and context window limits. filter_expr: Optional filter expression (e.g., "ActivityManager:I *:S") Use to focus on specific tags or priority levels max_size: Maximum output size in characters (default: 100000) Set to None for unlimited (not recommended) Returns: Recent logcat entries

devicelist

List all connected Android devices. Returns: A formatted list of connected devices with their basic information.

connect_device

Connect to an Android device over TCP/IP. Args: ip_address: The IP address of the device to connect to port: The port to connect to (default: 5555) Returns: A message indicating success or failure

disconnect_device

Disconnect from an Android device. Args: serial: Device serial number Returns: Disconnection result message

reboot_device

Reboot the device. Args: serial: Device serial number mode: Reboot mode - "normal", "recovery", or "bootloader" Returns: Reboot result message

capture_bugreport

Capture a bug report from a device. Bug reports are comprehensive diagnostic information packages that include system logs, device state, running processes, and more. Args: serial: Device serial number ctx: MCP context output_path: Where to save the bug report (leave empty to return as text) include_screenshots: Whether to include screenshots in the report timeout_seconds: Maximum time to wait for the bug report to complete (in seconds) Returns: Path to the saved bug report or a summary of the report contents

dump_heap

Capture a heap dump from a running process on the device. Heap dumps are useful for diagnosing memory issues, leaks, and understanding object relationships in running applications. Args: serial: Device serial number ctx: MCP context package_or_pid: App package name or process ID to dump output_path: Where to save the heap dump (leave empty for default location) native: Whether to capture a native heap dump (vs Java heap) timeout_seconds: Maximum time to wait for the heap dump to complete (in seconds) Returns: Path to the saved heap dump or an error message

list_directory

List contents of a directory on the device. Args: serial: Device serial number path: Directory path to list Returns: Directory listing

push_file

Upload a file to the device. Args: serial: Device serial number local_path: Path to the local file device_path: Destination path on the device Returns: Upload result message

pull_file

Download a file from the device to the local machine. Args: serial: Device serial number device_path: Path to the file on the device local_path: Destination path on the local machine Returns: Download result message

delete_file

Delete a file or directory from the device. Args: serial: Device serial number path: Path to the file or directory to delete Returns: Deletion result message

create_directory

Create a directory on the device. Args: serial: Device serial number path: Path to the directory to create Returns: Result message

file_exists

Check if a file exists on the device. Args: serial: Device serial number path: Path to the file on the device Returns: True if the file exists, False otherwise

read_file

Read the contents of a file on the device. Args: serial: Device serial number device_path: Path to the file on device max_size: Maximum file size to read in bytes (default: 100KB) Files larger than this will return an error message instead Returns: File contents as text or error message

write_file

Write text content to a file on the device. Args: serial: Device serial number device_path: Path to the file on device content: Text content to write to the file Returns: Writing result message

screenshot

Get a screenshot from a device. Args: serial: Device serial number ctx: MCP context quality: JPEG quality (1-100, lower means smaller file size) Returns: The device screenshot as an image

shell_command

Run a shell command on the device. Args: serial: Device serial number command: Shell command to run max_lines: Maximum lines of output to return (default: 1000) Use positive numbers for first N lines, negative for last N lines Set to None for unlimited (not recommended for large outputs) max_size: Maximum output size in characters (default: 100000) Limits total response size regardless of line count Returns: Command output

tap

Tap on the device screen at specific coordinates. Args: serial: Device serial number x: X coordinate to tap y: Y coordinate to tap Returns: The result of the tap operation

swipe

Perform a swipe gesture from one point to another on the device screen. Args: serial: Device serial number start_x: Starting X coordinate start_y: Starting Y coordinate end_x: Ending X coordinate end_y: Ending Y coordinate ctx: Context duration_ms: Duration of the swipe in milliseconds (default: 300) Returns: The result of the swipe operation

input_text

Input text on the device. Args: serial: Device serial number text: Text to input (will be typed as if from keyboard) Returns: The result of the text input operation

press_key

Press a key on the device. Common keycodes: - 3: HOME - 4: BACK - 24: VOLUME UP - 25: VOLUME DOWN - 26: POWER - 82: MENU Args: serial: Device serial number keycode: Android keycode to press Returns: The result of the key press operation

start_intent

Start an app activity using an intent. Args: serial: Device serial number package: Package name (e.g., "com.android.settings") activity: Activity name (e.g., ".Settings") ctx: Context extras: Optional intent extras as key-value pairs Returns: The result of the intent operation

README

✨ DroidMind 🤖

<div align="center">

Python 3.13+ License Status Code Style Type Check

通过模型上下文协议使用 AI 控制 Android 设备

</div>

DroidMind 是 AI 助手和 Android 设备之间强大的桥梁,可以通过自然语言实现控制、调试和系统分析。通过实施模型上下文协议 (MCP),DroidMind 允许 AI 模型通过 ADB 以安全、结构化的方式直接与 Android 设备交互。当用作代理编码工作流程的一部分时,DroidMind 可以让您的助手直接在循环中使用您的设备进行构建和调试。

💫 功能

  • 📱 设备控制 - 通过 USB 或 TCP/IP 连接到设备,运行 shell 命令,重启
  • 📊 系统分析 - 检查设备属性,查看硬件信息,分析系统日志
  • 🔍 文件系统访问 - 浏览目录内容并管理设备上的文件
  • 📷 可视化诊断 - 捕获设备屏幕截图以进行分析和调试
  • 📦 应用管理 - 在连接的设备上安装、卸载、启动、停止和清除应用数据
  • 🔄 多设备支持 - 控制和切换多个连接的设备
  • 👆 UI 自动化 - 通过点击、滑动、文本输入和按键与设备交互
  • 🔍 应用检查 - 查看应用清单、共享首选项和特定于应用的日志
  • 🔒 安全框架 - 通过全面的命令验证来保护设备
  • 💬 MCP 集成 - 与 Claude、Cursor、Cline 等无缝连接

🚀 安装

# 克隆仓库
git clone https://github.com/hyperbliss/droidmind.git
cd droidmind

# 使用 UV 设置虚拟环境
uv venv .venv
source .venv/bin/activate  # 在 Windows 上: .venv\Scripts\activate

# 使用 UV 安装依赖
uv sync

📋 前提条件

  • Python 3.13 或更高版本
  • 启用 USB 调试的 Android 设备
  • 已安装 ADB(Android 调试桥)并在 PATH 中
  • UV 包管理器(推荐用于依赖管理)
  • 对于网络控制:启用 ADB over TCP/IP 的 Android 设备

🔮 快速开始

运行 DroidMind 服务器

将 DroidMind 作为服务器运行,以通过 MCP 连接 AI 助手:

# 将 DroidMind 作为网络服务器启动
droidmind --transport sse

与 AI 助手一起使用

  1. 在 SSE 模式下启动 DroidMind:

    droidmind --transport sse
    
  2. 使用 MCP 协议 URI 连接您的 AI 助手:

    sse://localhost:4256/sse
    
  3. 现在,AI 可以通过自然语言控制您的 Android 设备了!

🛠️ 可用的 MCP 资源和工具

资源

  • devices://list - 列出所有连接的设备
  • device://{serial}/properties - 获取详细的设备属性
  • logs://{serial}/logcat - 获取设备最近的日志
  • logs://{serial}/anr - 获取应用程序无响应 (ANR) 跟踪
  • logs://{serial}/crashes - 获取应用程序崩溃日志
  • logs://{serial}/battery - 获取电池统计信息和历史记录
  • logs://{serial}/app/{package} - 获取特定于应用程序的日志
  • fs://{serial}/list/{path} - 列出设备上的目录内容
  • fs://{serial}/read/{path} - 从设备读取文件内容
  • fs://{serial}/stats/{path} - 获取详细的文件/目录统计信息
  • app://{serial}/{package}/manifest - 获取 AndroidManifest.xml 内容
  • app://{serial}/{package}/data - 列出应用程序数据目录中的文件
  • app://{serial}/{package}/shared_prefs - 获取应用程序的共享首选项

工具

  • devicelist - 列出所有连接的 Android 设备
  • device_properties - 获取特定设备的详细属性
  • device_logcat - 获取设备最近的 logcat 输出
  • list_directory - 列出设备上目录的内容
  • connect_device - 通过 TCP/IP 连接到设备
  • disconnect_device - 断开与 Android 设备的连接
  • shell_command - 在设备上运行 shell 命令
  • install_app - 在设备上安装 APK
  • uninstall_app - 从设备卸载应用程序
  • start_app - 启动设备上的应用程序
  • stop_app - 强制停止设备上的应用程序
  • clear_app_data - 清除应用程序数据和缓存
  • list_packages - 列出设备上已安装的软件包
  • get_app_manifest - 获取应用程序的 AndroidManifest.xml 内容
  • get_app_permissions - 获取应用程序请求的权限
  • get_app_activities - 获取应用程序中定义的活动
  • get_app_info - 获取有关应用程序的详细信息
  • reboot_device - 重新启动设备(正常、恢复或引导加载程序)
  • screenshot - 从设备获取屏幕截图
  • capture_bugreport - 从设备生成全面的错误报告
  • dump_heap - 从正在运行的进程创建堆转储以进行内存分析
  • push_file - 将文件上传到设备
  • pull_file - 从设备下载文件
  • delete_file - 从设备删除文件或目录
  • create_directory - 在设备上创建目录
  • file_exists - 检查设备上是否存在文件
  • read_file - 读取设备上文件的内容
  • write_file - 将文本内容写入设备上的文件
  • file_stats - 获取有关文件或目录的详细信息
  • tap - 点击设备屏幕上的特定坐标
  • swipe - 在屏幕上从一个点到另一个点执行滑动操作
  • input_text - 在设备上输入文本,就像从键盘输入一样
  • press_key - 按下硬件或软件键(例如,HOME、BACK、VOLUME)
  • start_intent - 使用 Android intent 启动应用程序活动

📊 AI 助手查询示例

通过连接到 DroidMind 的 AI 助手,尝试以下查询:

  • "列出所有连接的 Android 设备并显示它们的属性"
  • "连接到我在 192.168.1.100 的手机并检查其电池状态"
  • "截取我的 Pixel 的屏幕截图并告诉我当前屏幕上显示的内容"
  • "检查我的设备上的可用存储空间"
  • "显示我的设备的 ANR 跟踪和崩溃日志"
  • "查看最近的日志,告诉我是否有任何错误"
  • "在我的设备上安装此 APK 文件,并告诉我是否成功"
  • "在我的手机上显示所有已安装应用程序的列表"
  • "将我的设备重启到恢复模式"
  • "我的手机运行的是什么 Android 版本?"
  • "检查我的设备是否已 root,并告诉我它的安全补丁级别"
  • "显示 com.android.settings 的清单文件"
  • "检查我的应用程序的共享首选项"
  • "点击坐标 500,1000 处的“设置”图标"
  • "从屏幕顶部向下滑动以打开通知栏"
  • "将我的密码输入到当前文本字段中"
  • "按三次返回按钮以返回主屏幕"
  • "通过启动 com.android.settings 软件包来打开“设置”应用程序"

🔒 安全特性

DroidMind 包含一个全面的安全框架,可在允许 AI 助手具有表现力的同时保护您的设备:

  • 命令验证:所有 shell 命令都根据安全命令的允许列表进行验证
  • 风险评估:命令按风险级别(安全、低、中、高、严重)进行分类
  • 命令清理:输入经过清理以防止命令注入攻击
  • 受保护的路径:系统目录和关键路径受到保护,免受修改
  • 全面日志记录:所有命令及其风险级别都会被记录以进行审计
  • 可疑模式检测:具有潜在危险模式的命令被阻止
  • ADB 命令安全性:特殊处理 ADB 特定命令,并进行适当的异步验证

安全系统旨在足够宽松以允许常见操作,同时防止破坏性操作。高风险命令在执行前会向用户显示警告,并且未经明确覆盖,关键操作将被完全阻止。

💻 开发

DroidMind 使用 UV 进行依赖管理和开发工作流程。 UV 是一种快速、可靠的 Python 包管理器和解析器。

# 更新依赖
uv sync

# 运行测试
pytest

# 运行 linting
ruff check .

# 运行类型检查
mypy .

🤝 贡献

欢迎贡献!请随时提交 Pull Request。

  1. Fork 仓库
  2. 创建您的功能分支 (git checkout -b feature/amazing-feature)
  3. 使用 UV 设置您的开发环境
  4. 进行更改
  5. 运行测试和 linting
  6. 提交您的更改 (git commit -m 'Add some amazing feature')
  7. 推送到分支 (git push origin feature/amazing-feature)
  8. 打开 Pull Request

📝 许可证

该项目已获得 Apache 许可证的许可 - 有关详细信息,请参阅 LICENSE 文件。


<div align="center">

Stefanie Jane 🌠 创建

如果您觉得 DroidMind 有用,请给我买一罐 Monster Ultra Violet ⚡️

</div>

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选