mobile-mcp
基于 Model Context Protocol 的移动端自动化服务器,把 iOS/Android 真机、模拟器、仿真器上的点击、滑动、装包、日志抓取等操作封装成 MCP 工具,供 Claude Code、Cursor、Codex 等 Agent 直接调用。亮点是优先走原生无障碍树而非视觉模型,省 token 且更快,一套接口同时覆盖两个平台,适合把移动端测试、表单填写和多步用户旅程交给 agent 执行。默认收集匿名遥测,可用 MOBILEMCPDISABLETELEMETRY 关闭。
README
Mobile Next - 面向移动开发与自动化的 MCP server | iOS、Android、Simulator、Emulator 与真机
这是一个 MCP Server,通过平台无关的接口实现可扩展的移动自动化与开发,无需分别掌握 iOS 或 Android 的知识。你可以在 emulator、simulator 和真机(iOS 与 Android)上运行它。
该 server 让 Agent 和 LLM 能够通过结构化 accessibility snapshot,或基于截图的坐标点击,与原生 iOS/Android 应用及设备交互。
兼容 Claude Code、Codex、Gemini、GitHub Copilot、Antigravity —— 或任何兼容 MCP 的客户端。
既可以在你自己的机器上对设备运行,也可以通过 Mobile Next Cloud 对云端的真实 iOS 与 Android 设备运行 —— 工具相同,无需本地环境搭建。
https://github.com/user-attachments/assets/bb084777-beb3-4930-ae6f-8d3fe694ddde
主要使用场景
我们如何帮助扩展移动自动化:
- 📲 原生应用自动化(iOS 与 Android),用于测试或数据录入场景。
- 📝 脚本化流程与表单交互,无需手动操控 simulator/emulator 或真机(iPhone、Samsung、Google Pixel 等)
- 🧭 由 LLM 驱动的多步骤用户旅程自动化
- 👆 面向 agent 框架的通用移动应用交互
- 🤖 为移动自动化用例与数据提取实现 agent-to-agent 通信
主要特性
- 🚀 Accessibility 优先 —— 快速且低成本:通过原生 accessibility tree 驱动应用(无需 vision model,不消耗图像 token),仅在必要时回退到截图 + 坐标。
- 📱 一套 API,覆盖所有目标:相同的工具在 iOS 和 Android 上通用 —— simulator、emulator 和真机皆可。
- 🧠 无需平台专业知识:不需要 XCUITest,不需要 Espresso,不需要各平台专属的胶水代码 —— 描述目标,agent 来完成。
- 🧰 完整的设备控制:点击、滑动与手势;应用安装/启动/终止;屏幕录制;硬件按键;deep link;屏幕方向。
- 📊 结构化、确定性的输出:读取真实 UI 元素并提取结构化数据,减少纯截图方案的歧义。
🎯 平台支持
| 目标 | 支持 | 环境准备 |
|---|---|---|
| iOS Simulator | ✅ | Xcode + 已启动的 simulator(xcrun simctl) |
| iOS 真机 | ✅ | 设备通过 USB 连接并已信任 |
| Android Emulator | ✅ | Android SDK + 正在运行的 emulator(adb) |
| Android 真机 | ✅ | adb + 已启用并授权的 USB 调试 |
🔧 可用的 MCP 工具
设备管理
mobile_list_available_devices- 列出所有可用设备(simulator、emulator 和真机)mobile_get_screen_size- 获取移动设备的屏幕尺寸(以像素为单位)mobile_get_orientation- 获取设备当前的屏幕方向mobile_set_orientation- 更改屏幕方向(竖屏/横屏)mobile_set_location- 覆盖设备上报的 GPS 位置,或清除该覆盖mobile_clipboard- 读取或替换设备剪贴板
远程设备(Mobile Next Cloud)
mobile_login_to_cloud_provider- 让本机通过云端设备提供商完成认证(基于浏览器的 device-code 登录)mobile_list_remote_devices- 列出可从云端设备池中预留的设备型号mobile_allocate_remote_device- 预留一台物理云设备以供独占使用mobile_release_remote_device- 将已预留的云设备释放回设备池
应用管理
mobile_list_apps- 列出设备上所有已安装的应用mobile_get_foreground_app- 获取当前处于前台的应用mobile_launch_app- 使用包名启动应用mobile_terminate_app- 停止并终止正在运行的应用mobile_install_app- 从文件安装应用(.apk、.ipa、.app、.zip)mobile_uninstall_app- 使用 bundle ID 或包名卸载应用
屏幕交互
mobile_take_screenshot- 截取屏幕截图以了解屏幕上的内容mobile_save_screenshot- 将截图保存到文件mobile_list_elements_on_screen- 列出 UI 元素及其坐标与属性mobile_click_on_screen_at_coordinates- 在指定的 x,y 坐标处点击mobile_double_tap_on_screen- 在指定坐标处双击mobile_long_press_on_screen_at_coordinates- 在指定坐标处长按mobile_swipe_on_screen- 向任意方向滑动(上、下、左、右)mobile_start_screen_recording- 开始将设备屏幕录制到视频文件mobile_stop_screen_recording- 停止当前屏幕录制并保存视频
输入与导航
mobile_type_keys- 向获得焦点的元素输入文本,可选提交mobile_press_button- 按下设备按键(HOME、BACK、VOLUME_UP/DOWN、ENTER 等)mobile_open_url- 在设备浏览器中打开 URL
日志与崩溃报告
mobile_get_device_logs- 采集实时设备日志(Android 上的 logcat、iOS 上的 unified log),可选择保存到文件mobile_list_crashes- 列出设备上可用的崩溃报告mobile_get_crash- 根据 ID 获取崩溃报告的完整内容mobile_batch_commands- 在一次调用中按顺序运行多个工具(例如点击、输入、点击),可选择在末尾列出屏幕元素
🏗️ Mobile MCP 架构
📚 Wiki 页面
关于安装配置与调试的相关问题,详见我们的 wiki 页面。
前置条件
将 MCP 与你的 agent 和移动设备连接,你需要:
- Xcode command line tools
- Android Platform Tools
- node.js v20+
- 支持 MCP 的基础模型或 agent,例如 Claude MCP、OpenAI Agent SDK、Copilot Studio
安装与配置
标准配置在大多数工具中均可使用:
{
"mcpServers": {
"mobile-mcp": {
"command": "npx",
"args": ["-y", "@mobilenext/mobile-mcp@latest"]
}
}
}
Amp通过 Amp VS Code 扩展的设置界面添加,或更新你的 settings.json 文件:
"amp.mcpServers": {
"mobile-mcp": {
"command": "npx",
"args": [
"@mobilenext/mobile-mcp@latest"
]
}
}
Amp CLI:
在终端中运行以下命令:
amp mcp add mobile-mcp -- npx @mobilenext/mobile-mcp@latest
Antigravity 2Antigravity 没有用于添加 MCP server 的 CLI 命令,因此需要手动添加。编辑 ~/.gemini/config/mcp_config.json 并加入:
{
"mcpServers": {
"mobile-mcp": {
"command": "npx",
"args": ["-y", "@mobilenext/mobile-mcp@latest"]
}
}
}
Cline要配置 Cline,只需将上面的 json 添加到你的 MCP 设置文件中。
Claude Code使用 Claude Code CLI 添加 Mobile MCP server:
claude mcp add mobile-mcp -- npx -y @mobilenext/mobile-mcp@latest
Claude Desktop遵循 MCP 安装指南,使用上面的 json 配置。
Codex使用 Codex CLI 添加 Mobile MCP server:
codex mcp add mobile-mcp npx "@mobilenext/mobile-mcp@latest"
或者,创建或编辑配置文件 ~/.codex/config.toml 并加入:
[mcp_servers.mobile-mcp]
command = "npx"
args = ["@mobilenext/mobile-mcp@latest"]
更多信息请参阅 Codex MCP 文档。
Copilot使用 Copilot CLI 以交互方式添加 Mobile MCP server:
/mcp add
你可以编辑配置文件 ~/.copilot/mcp-config.json 并加入:
{
"mcpServers": {
"mobile-mcp": {
"type": "local",
"command": "npx",
"tools": [
"*"
],
"args": [
"@mobilenext/mobile-mcp@latest"
]
}
}
}
更多信息请参阅 Copilot CLI 文档。
Cursor点击按钮进行安装:
或手动安装:
前往 Cursor Settings -> MCP -> Add new MCP Server。随意命名,类型选择 command,命令为 npx -y @mobilenext/mobile-mcp@latest。你也可以通过点击 Edit 来验证配置或添加命令参数。
使用 Gemini CLI 添加 Mobile MCP server:
gemini mcp add mobile-mcp npx -y @mobilenext/mobile-mcp@latest
Goose点击按钮进行安装:
或手动安装:
前往 Advanced settings -> Extensions -> Add custom extension。随意命名,类型选择 STDIO,并将 command 设置为 npx -y @mobilenext/mobile-mcp@latest。点击 "Add Extension"。
遵循 MCP Servers 文档。例如在 .kiro/settings/mcp.json 中:
{
"mcpServers": {
"mobile-mcp": {
"command": "npx",
"args": [
"@mobilenext/mobile-mcp@latest"
]
}
}
}
opencode遵循 MCP Servers 文档。例如在 ~/.config/opencode/opencode.json 中:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"mobile-mcp": {
"type": "local",
"command": [
"npx",
"@mobilenext/mobile-mcp@latest"
],
"enabled": true
}
}
}
Windsurf打开 Windsurf 设置,进入 MCP servers,使用 command 类型添加一个新的 server:
npx @mobilenext/mobile-mcp@latest
或者按上文所示,在你的设置中的 mcpServers 下添加标准配置。
✅ 验证是否可用
server 配置完成后,让你的 agent 列出设备:
列出可用设备
你应该会得到正在运行的 simulator、emulator 以及已连接的设备。如果是这样,说明 Mobile MCP 已正确接入。如果列表为空,请确认有 simulator 或 emulator 正在运行(参见前置条件)—— 需要更多帮助,请查看 wiki。
☁️ 扩展规模,使用云设备
想扩展到成百上千台设备?想在 CI/CD 流水线中使用 Mobile MCP?
在你的 Agent 中提示:
log in to mobile next cloud and then show me which remote devices are available to me
Streamable HTTP Server 模式
默认情况下,Mobile MCP 通过 stdio 运行。若要改为启动一个 Streamable HTTP server,请使用 --listen 标志:
npx @mobilenext/mobile-mcp@latest --listen 3000
这会绑定到 localhost:3000。若要绑定到特定网卡:
npx @mobilenext/mobile-mcp@latest --listen 0.0.0.0:3000
然后配置你的 MCP 客户端连接到 http://<host>:3000/mcp(或位于 TLS 之后的 https://…/mcp)。该端点接受 Streamable HTTP(对 /mcp 发起 POST);远程模式是无状态的(不需要 session affinity),这在与 Smithery 及其他横向扩展托管平台配合时效果良好。
迁移说明:
--listen此前在/mcp上提供的是已废弃的 HTTP+SSE transport。客户端必须使用 Streamable HTTP 访问http(s)://host:port/mcp。/mcp上旧的纯 SSE 流程已不再可用。
绑定到 localhost 时,会自动启用 Host header DNS rebinding 防护。
授权
若要在 HTTP server 上要求 Bearer token 授权,请设置 MOBILEMCP_AUTH 环境变量:
MOBILEMCP_AUTH=my-secret-token npx @mobilenext/mobile-mcp@latest --listen 3000
设置后,所有请求都必须包含头 Authorization: Bearer my-secret-token。未设置时,server 接受未认证的连接并记录一条警告。
🛠️ 如何使用
将 MCP server 添加到你的 IDE/客户端后,你可以指示 AI 助手使用可用的工具。 例如,在 Cursor 的 agent 模式下,你可以使用下面的提示词快速验证、测试并迭代 UI 交互、读取屏幕信息、走通复杂的工作流。 提示词要描述清楚、直击要点。
✨ 示例提示词
工作流
你可以在单条提示词中指定详细的工作流、验证业务逻辑、搭建自动化。你可以尽情发挥:
搜索一个视频,评论、点赞并分享它。
Find the video called " Beginner Recipe for Tonkotsu Ramen" by Way of
Ramen, click on like video, after liking write a comment " this was
delicious, will make it next Friday", share the video with the first
contact in your whatsapp list.
下载一个优质的计步应用,注册、设置锻炼并给应用打 5 星
Find and Download a free "Pomodoro" app that has more than 1k stars.
Launch the app, register with my email, after registration find how to
start a pomodoro timer. When the pomodoro timer started, go back to the
app store and rate the app 5 stars, and leave a comment how useful the
app is.
在 Substack 中搜索、阅读、高亮、评论并保存一篇文章
Open Substack website, search for "Latest trends in AI automation 2025",
open the first article, highlight the section titled "Emerging AI trends",
and save article to reading list for later review, comment a random
paragraph summary.
预订一节健身课程,设置定时器
Open ClassPass, search for yoga classes tomorrow morning within 2 miles,
book the highest-rated class at 7 AM, confirm reservation,
setup a timer for the booked slot in the phone
查找本地活动,创建日历事件
Open Eventbrite, search for AI startup meetup events happening this
weekend in "Austin, TX", select the most popular one, register and RSVP
yes to the event, setup a calendar event as a reminder.
查看天气预报并发送 Whatsapp/Telegram/Slack 消息
Open Weather app, check tomorrow's weather forecast for "Berlin", and
send the summary via Whatsapp/Telegram/Slack to contact "Lauren Trown",
thumbs up their response.
- 在 Zoom 中安排会议并通过邮件分享邀请
Open Zoom app, schedule a meeting titled "AI Hackathon" for tomorrow at
10AM with a duration of 1 hour, copy the invitation link, and send it via
Gmail to contacts "team@example.com".
运行与配置
环境变量
| 变量 | 说明 | 示例 |
|---|---|---|
MOBILEMCP_AUTH |
在 Streamable HTTP server(--listen)上要求 Bearer token —— 此后每个请求都必须发送 Authorization: Bearer <token>。 |
MOBILEMCP_AUTH=my-secret-token |
MOBILEMCP_DISABLE_TELEMETRY |
禁用匿名使用遥测。 | MOBILEMCP_DISABLE_TELEMETRY=1 |
MOBILEMCP_ALLOW_UNSAFE_URLS |
允许 mobile_open_url 打开非标准 URL scheme(默认被阻止)。 |
MOBILEMCP_ALLOW_UNSAFE_URLS=1 |
MOBILEMCP_LEGACY_ROBOT |
对 Android 设备和物理 iOS 设备使用旧版平台专属 robot。iOS simulator 继续使用 mobilecli。 |
MOBILEMCP_LEGACY_ROBOT=1 |
Simulator、Emulator 与真机
启动后,Mobile MCP 可以连接到:
- macOS/Linux 上的 iOS Simulator
- Linux/Windows/macOS 上的 Android Emulator
- iOS 或 Android 真机(需要相应的平台工具与驱动)
在运行 Mobile Next Mobile MCP 之前,请确保你已正确安装并配置移动平台 SDK(Xcode、Android SDK)。
遥测
Mobile MCP 通过 PostHog 和 Scarf 收集匿名使用遥测。要禁用它,请设置 MOBILEMCP_DISABLE_TELEMETRY 环境变量:
MOBILEMCP_DISABLE_TELEMETRY=1 npx @mobilenext/mobile-mcp@latest
对于 json 配置:
{
"mcpServers": {
"mobile-mcp": {
"command": "npx",
"args": ["-y", "@mobilenext/mobile-mcp@latest"],
"env": {
"MOBILEMCP_DISABLE_TELEMETRY": "1"
}
}
}
}
在 Simulator/Emulator 上以 "headless" 模式运行
当你没有真机连接到本机时,可以在后台以 emulator 或 simulator 运行 Mobile MCP。
例如,在 Android 上:
- 启动一个 emulator(avdmanager / emulator 命令)。
- 使用所需标志运行 Mobile MCP
在 iOS 上,你需要 Xcode,并在将 Mobile MCP 与该 simulator 实例配合使用前先运行 Simulator。
xcrun simctl listxcrun simctl boot "iPhone 16"
🧩 Mobile Next 的一部分
Mobile MCP 是驱动真实移动设备工具链中的一环:
- mobilewright —— “移动端的 Playwright”。当你准备把 agent 驱动的探索转化为 iOS 与 Android 上可重复、确定性的测试时,就该进阶到 mobilewright。
- mobilecli —— Mobile MCP 所构建于其上的通用设备 CLI:从命令行或 JSON-RPC API 控制设备、simulator 和 emulator。
- Mobile Next Cloud —— 同样的技术栈,租用形式:按需获取真实 iOS 与 Android 设备。只需向你的 agent 提示:
log in to mobile next cloud and then show me which remote devices are available to me即可开始。
🚀 路线图
我们持续改进 Mobile MCP。可在 ROADMAP.md 中了解我们接下来要构建的内容 —— 优先级很大程度上由社区反馈决定,所以请告诉我们你希望看到什么。
🤝 贡献
欢迎贡献 —— 代码、文档、bug 报告和想法。
- ⭐ 为仓库点星 —— 帮助他人发现 Mobile MCP 的最简单方式。
- 阅读 CONTRIBUTING.md 了解如何构建、测试和提交 pull request。
- 浏览开放的 issue 寻找可以着手的任务。
- 也欢迎在我们的 Slack 社区中提问和交流想法。
也请阅读我们的行为准则。
感谢所有贡献者 ❤️
我们感激每一位帮助改进本项目的人。
隐私政策
Mobile MCP 在本地运行,仅与你连接的设备通信。 有关数据收集、使用、保留及联系方式,请查看 Mobile Next 隐私政策:https://mobilenext.ai/privacy。