
Maestro MCP
MCP移动端 UI 测试框架 Maestro 的 CLI 内置 MCP(maestro mcp):让 agent 在 iOS / Android 模拟器、Android 真机或 Chromium 浏览器上查看屏幕、点击、滚动、断言,并编写和运行 YAML 端到端测试流程。需安装 Maestro CLI 与 Java 17+,官方维护。
Maestro MCP Server
Overview
The Maestro MCP (Model Context Protocol) server enables LLM-driven automation and orchestration of Maestro commands and device management. It serves two primary functions for calling LLMs:
- enables LLMs to directly control and interact with devices using Maestro device capabilities
- enables LLMs to write, validate, and run Maestro code (flows)
The MCP server is designed to be extensible, maintainable, and easy to run as part of the Maestro CLI. It supports real-time device management, app automation, and more, all via a standardized protocol.
Features
- Exposes Maestro device and automation commands as MCP tools
- Supports listing, launching, and interacting with devices
- Supports running inline flow YAML, specific test files, or entire flow directories (syntax is validated on execution)
- Easily extensible: add new tools with minimal boilerplate
- Includes a test script and config for automated validation
Running the MCP Server
To use the MCP server as an end user, after following the maestro install instructions run:
maestro mcp
This launches the MCP server via the Maestro CLI, exposing Maestro tools over STDIO for LLM agents and other clients.
The command also starts Maestro Viewer as a local HTTP server in the same process and prints its URL to stderr:
mcp_viewer_ready http://127.0.0.1:<port>
Use maestro mcp --no-viewer to disable it, or maestro mcp --viewer-port 9999 to choose a fixed port.
Viewer development
The viewer is authored as a small React app in maestro-cli/mcp-viewer using npm, Vite, and Tailwind CSS v4.
For fast UI iteration without rebuilding the CLI or running the MCP server:
cd maestro-cli/mcp-viewer
npm install
npm run dev
For the CLI distribution, Gradle runs npm run build, which compiles the React app and inlines the generated JavaScript and CSS into one HTML resource at maestro-cli/mcp-viewer/build/raw/index.html.
The viewer accepts lightweight runtime events via POST /api/events and streams them to connected browsers with GET /api/events/stream. Keep this route payload small and generic until the MCP server and Maestro driver event boundaries are more settled.
Developing
Extending the MCP Server
To add a new tool:
- Create a new file in
maestro-cli/src/main/java/maestro/cli/mcp/tools/following the same patterns as the other tools. - Add your tool to the
addToolscall inMcpServer.kt - Build the CLI with
./gradlew :maestro-cli:installDist - Test your tool by running
./maestro-cli/src/test/mcp/test-single-mcp-tool.shwith appropriate args for your tool
Evals testing
When testing a Maestro MCP tool, it's important to test not only that it works correctly but that LLMs can call it correctly and use the output appropriately. This happens less frequently than is expected. Make sure to add relevant test cases to our evals framework in ./maestro-cli/src/test/mcp/maestro-evals.yaml, and then run the eval test suite with:
ANTHROPIC_API_KEY=<your_key> ./maestro-cli/src/test/mcp/run-mcp-server-evals.sh
Implementation Notes & Rationale
Using forked version of official kotlin MCP SDK
The official MCP Kotlin SDK can't be used directly because it requires Java 21 and Kotlin 2.x, while Maestro is built on Java 8 and Kotlin 1.8.x for broad compatibility. However, we want to be able to benefit from features added to the SDK since the MCP spec is changing rapidly. So we created a fork that "downgrades" the reference SDK to Java 8 and Kotlin 1.8.22.
Why Integrate MCP Server Directly Into maestro-cli?
- Dependency Management: The MCP server needs access to abstractions like
MaestroSessionManagerand other CLI internals. Placing it in a separate module (e.g.,maestro-mcp) would create a circular dependency betweenmaestro-cliand the new module. - Simplicity: Keeping all MCP logic within
maestro-cliavoids complex build configurations and makes the integration easier to maintain and review. - Extensibility: This approach allows new tools to be added with minimal boilerplate and direct access to CLI features.
Potential Future Improvements
- Shared Abstractions: If more MCP-related code or other integrations are needed, consider extracting shared abstractions (e.g., session management, tool interfaces) into a
commonorcoremodule. This would allow for a clean separation and potentially enable a standalonemaestro-mcpmodule. - Streamable HTTP: The MCP tool channel currently uses STDIO; the viewer-side HTTP server is unrelated. Adding a Streamable HTTP transport for MCP tool calls is still future work.
相關資源

Midscene Skills
Skill基于 Midscene.js 视觉识别的跨平台 UI 自动化技能合集:用自然语言操控浏览器、桌面、Android、iOS 与鸿蒙设备,并可搭建 Vitest + Midscene E2E 测试。需自备视觉模型 API Key,Midscene 官方维护。
web-infra-dev/midscene-skills329
Mobile MCP
MCP让 agent 操作 iOS / Android 的模拟器与真机:优先读取无障碍树,必要时按截图坐标点击,还能滑动、装卸应用、录屏和读取设备日志。本机需装好 Xcode 或 Android 平台工具。
mobile-next/mobile-mcp11.1k
MCP Appium
MCPAppium 官方 MCP 服务:让 agent 在 Android / iOS 模拟器与真机上创建会话、定位元素、点击输入与截图,并生成 Java/TestNG 测试代码。需准备 Android SDK 或 Xcode。
appium/appium-mcp523
Maestro
CLI用 YAML 编写 Android、iOS 与 Web 应用的端到端 UI 测试;CLI 内置 MCP 服务器(maestro mcp),编码 agent 可在模拟器上点击、断言并生成测试。需 Java 17+。
mobile-dev-inc/Maestro16.6k
agent-device
CLICallstack 出品,让编码 agent 通过无障碍快照操作并验证 iOS、Android、鸿蒙与桌面应用:点击、填表、截图、日志与性能采样,内置 MCP 服务器。需 Node.js 22.12+。
callstack/agent-device5.6k
Expo CLI
CLIExpo 官方命令行:启动 React Native 本地开发服务器、预构建原生目录(prebuild)、在 iOS/Android 上本地运行,并安装版本匹配的依赖;随 expo 包提供,在项目内用 npx expo 调用。
expo/expo53.9k