maestro-cli/src/main/java/maestro/cli/mcp/README.md
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:
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.
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.
To add a new tool:
maestro-cli/src/main/java/maestro/cli/mcp/tools/ following the same patterns as the other tools.addTools call in McpServer.kt./gradlew :maestro-cli:installDist./maestro-cli/src/test/mcp/test-single-mcp-tool.sh with appropriate args for your toolWhen 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
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.
maestro-cli?MaestroSessionManager and other CLI internals. Placing it in a separate module (e.g., maestro-mcp) would create a circular dependency between maestro-cli and the new module.maestro-cli avoids complex build configurations and makes the integration easier to maintain and review.common or core module. This would allow for a clean separation and potentially enable a standalone maestro-mcp module.