
Appium
STDIO移动设备自动化测试MCP服务器
移动设备自动化测试MCP服务器
Appium MCP Server 是一个基于 Model Context Protocol (MCP) 的移动设备自动化测试服务器。它将 Appium 的强大功能通过 MCP 协议暴露给 AI 助手,实现智能化的移动应用测试。
# 安装 Appium MCP Server pip install appium-mcp-server # 安装 Appium npm install -g appium appium driver install uiautomator2 # Android appium driver install xcuitest # iOS (仅 macOS)
前置条件检查:
# 验证安装是否成功 appium-mcp-server --version # 应该显示版本号 appium --version # 应该显示 Appium 版本
启动 Appium 服务器
appium --port 4723
配置 Claude Desktop
{ "mcpServers": { "appium": { "command": "appium-mcp-server", "args": ["run"] } } }
注意:配置后重启 Claude Desktop,MCP 服务器会自动启动,无需手动运行。
重启 Claude Desktop
配置文件修改后,需要重启 Claude Desktop 使配置生效。
开始对话
请帮我连接 Android 设备,启动设置应用并截图。
展示完整的设备管理流程:设备发现 → 设备连接 → 信息获取 → 会话管理 → 截图验证
# Python 客户端示例 import asyncio from mcp import ClientSession, StdioServerParameters from mcp.client.stdio import stdio_client async def test_login(): server_params = StdioServerParameters( command="appium-mcp-server", args=[] ) async with stdio_client(server_params) as (read, write): async with ClientSession(read, write) as session: await session.initialize() # 连接设备 await session.call_tool("connect_device", { "device_id": "emulator-5554" }) # 启动应用 await session.call_tool("launch_app", { "device_id": "emulator-5554", "app_package": "com.example.app" }) # 执行登录流程 # ...
用户: 请测试购物应用的结账流程
AI: 我来帮您测试购物应用的结账流程:
1. 首先连接设备并启动应用
2. 添加商品到购物车
3. 进入结账页面
4. 填写收货信息
5. 选择支付方式
6. 完成下单并验证
让我开始执行测试...
graph TB subgraph "MCP Client Layer" A[AI Assistant] B[Claude Desktop] C[Custom Client] end subgraph "Appium MCP Server" D[MCP Server Core] E[Tool Registry] F[Device Manager] G[Session Manager] end subgraph "Appium Layer" H[Appium Python Client] I[WebDriver Sessions] end subgraph "Device Layer" J[Android Devices] K[iOS Devices] L[Emulators] end A --> D B --> D C --> D D --> E D --> F D --> G E --> H F --> H G --> I H --> J H --> K H --> L
我们欢迎社区贡献!请查看 贡献指南 了解如何参与项目开发。
# 克隆项目 git clone https://github.com/1405942836/appium-mcp.git cd appium-mcp # 安装开发依赖 pip install -e ".[dev]" # 安装 pre-commit hooks pre-commit install # 运行测试 pytest
本项目基于 MIT 许可证 开源。
⭐ 如果这个项目对您有帮助,请给我们一个 Star!