移动端自动化测试框架 - 支持Android和iOS,集成AI增强功能
Project description
Mobile MCP - 移动端自动化测试框架
📁 目录结构
backend/mobile_mcp/
├── core/ # 核心功能模块
│ ├── locator/ # 定位器(包括Cursor AI视觉识别)
│ ├── ai/ # AI分析模块
│ ├── assertion/ # 断言模块
│ ├── h5/ # H5处理模块
│ ├── device_manager.py # 设备管理
│ └── mobile_client.py # 移动端客户端
│
├── mcp/ # MCP服务器相关
│ └── mcp_server.py # MCP服务器(Cursor AI工具)
│
├── examples/ # 测试示例
│ └── test_*.py # 各种测试用例
│
├── screenshots/ # 截图目录
│ ├── requests/ # 分析请求文件(JSON)
│ └── results/ # 分析结果文件(JSON,由Cursor AI写入)
│
├── docs/ # 文档目录
│ ├── md/ # Markdown文档
│ └── *.txt # 其他文档
│
├── workspace/ # 工作区配置
│ └── *.code-workspace # VS Code工作区文件
│
├── tools/ # 工具脚本
├── utils/ # 工具函数
├── vision/ # 视觉识别模块
├── tests/ # 测试文件
└── requirements.txt # 依赖列表
🎯 核心功能
1. 智能定位系统
- 规则匹配(免费,85%)
- XML深度分析(免费,5%)
- 位置分析(免费,5%)
- 视觉识别(付费,4%)
- Cursor AI视觉识别(免费,1%) ⭐ 新增
2. Cursor AI自动视觉识别
- 自动截图(智能区域选择)
- 自动创建分析请求
- Cursor AI自动分析
- 自动获取坐标并点击
- 自动更新脚本
📖 文档
- 📘 使用指南(推荐) - 完整的安装和使用说明
- 🌐 局域网共享部署 - HTTP服务器部署指南(方案2)
- 完整流程指南
- 使用说明
- MCP设置
🚀 快速开始
1. 安装依赖
cd backend/mobile_mcp
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
2. 配置 Cursor
在 Cursor Settings 中添加 MCP Server 配置:
{
"mcpServers": {
"mobile-automation": {
"command": "python",
"args": ["/绝对路径/to/douzi-ai/backend/mobile_mcp/mcp/mcp_server.py"],
"env": {
"PYTHONPATH": "/绝对路径/to/douzi-ai",
"MOBILE_DEVICE_ID": "auto"
}
}
}
}
3. 连接设备
adb devices
4. 重启 Cursor 并开始使用
重启 Cursor 后,直接用自然语言告诉 AI:
打开 com.im30.way,点击登录按钮
详细说明请查看 使用指南
🌐 局域网共享(HTTP Server)
如果你想在局域网内共享MCP服务,让其他人无需安装依赖:
快速启动
cd backend/mobile_mcp
# 安装HTTP服务器依赖
pip install fastapi uvicorn
# 启动服务器
python mcp/mcp_http_server.py
# 或使用启动脚本(自动获取IP)
./start_http_server.sh
服务器启动后会显示你的IP地址,其他人可以通过HTTP API访问。
详细说明请查看 部署指南
🚀 快速开始(旧版)
cd backend/mobile_mcp
source venv/bin/activate
python examples/test_设置切换语言_完整版.py
📝 使用示例
当定位失败时,系统会自动:
- 截图并创建请求文件
- 等待Cursor AI分析(最多30秒)
- 在Cursor中调用:
@mobile_analyze_screenshot request_id="xxx" - Cursor AI分析并写入结果文件
- 测试脚本继续执行
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mobile_mcp_ai-1.0.0.tar.gz
(140.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
mobile_mcp_ai-1.0.0-py3-none-any.whl
(115.1 kB
view details)
File details
Details for the file mobile_mcp_ai-1.0.0.tar.gz.
File metadata
- Download URL: mobile_mcp_ai-1.0.0.tar.gz
- Upload date:
- Size: 140.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8751e0cfb5eeee1390c68a9bf12e92ad5ac890ef38195c42b798d112f85b5f4
|
|
| MD5 |
39a98e4b052ea6bb7aba24882ea6f0ab
|
|
| BLAKE2b-256 |
8fc34f54fdc4f217c680fd2c426bacffbf4d651321de72eccc2481df6ae1d3a9
|
File details
Details for the file mobile_mcp_ai-1.0.0-py3-none-any.whl.
File metadata
- Download URL: mobile_mcp_ai-1.0.0-py3-none-any.whl
- Upload date:
- Size: 115.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a02e3ae8a11c9338be42ad05739b3b84d0867bcef33871ffdfa51013fbe3c7ad
|
|
| MD5 |
430d54f3656791a4bcfbfc4c4942424d
|
|
| BLAKE2b-256 |
566a94a4e83fb1248bd1a1e315f89f6790fc37778bc0ce667c17cbb1dd7162e6
|