MCP server for Flutter and Maestro
Flutter Maestro MCP Server
Experimental Model Context Protocol (MCP) server that enables AI agents to interact with running Flutter applications via the VM Service and execute Maestro flows. Just for playing around with custom MCPs
Prerequisites
- Maestro CLI: Required for running Maestro flows with the
run_maestro_flowtool.- Install via Homebrew:
brew install maestro - Or follow the official installation guide
- Install via Homebrew:
Installation
- Clone this repository.
- Run
dart pub getto install dependencies.
Configuration
VS Code
Add the following to your MCP settings file (typically ~/.vscode/mcp.json or similar, depending on the extension):
{
"servers": {
"flutter-maestro": {
"command": "dart",
"args": [
"/absolute/path/to/flutter_maestro_mcp/bin/flutter_maestro_mcp.dart"
]
}
}
}
Note: Replace /absolute/path/to/flutter_maestro_mcp with the actual path to your cloned repository.
Testing with Example App
This repository includes an example Flutter application instrumented with test hooks to verify the MCP server functionality.
Using VS Code (Recommended):
- Open the repository in VS Code.
- Go to Run and Debug and select "Flutter Example App".
- Copy the VM Service URI from the Debug Console.
Using Command Line:
- Navigate to
example/. - Run the app:
flutter run. - Note the VM Service URI from the output (e.g.,
ws://127.0.0.1:12345/ws).
Once Running:
- Copy the complete VM Service URI from the Flutter app output
- Use the
connecttool with this URI - Try tools like
inspect_uiandtapto interact with the running example app
Finding the VM Service URI:
The VM Service URI is printed when your Flutter app starts. You MUST copy the complete URI including the authentication token:
- VS Code Debug Console: Search for "VM Service" or "Observatory"
- Flutter CLI output: Look for "The Dart VM service is listening on ws://..."
- URI format:
ws://127.0.0.1:PORT/AUTH_TOKEN/ws - Example:
ws://127.0.0.1:59548/-ppep2G-MyI=/ws
⚠️ Important: Auto-discovery is not supported. You must provide the complete URI with the authentication token. The token is only printed once at app startup and cannot be retrieved later.
Available Tools
connect: Connect to a running Flutter app using its VM Service URI.- Arguments:
uri(required - the complete VM Service WebSocket URI including auth token from your Flutter app output, e.g.,ws://127.0.0.1:59548/-ppep2G-MyI=/ws)
- Arguments:
disconnect: Disconnect from the current Flutter app.inspect_ui: Get a simplified JSON representation of the current UI hierarchy (keys, text, semantics).tap: Tap on a widget matching criteria.- Arguments:
key,text,tooltip,semantics
- Arguments:
enter_text: Enter text into a widget matching criteria.- Arguments:
input(required), plus matcher arguments (key,text, etc.)
- Arguments:
scroll_to: Scroll until a widget is visible.- Arguments: Matcher arguments (
key,text, etc.)
- Arguments: Matcher arguments (
take_screenshot: Take a screenshot of the current screen.get_logs: Retrieve application logs.hot_reload: Trigger a hot reload.write_maestro_flow: Write a Maestro YAML flow to a file.- Arguments:
path,content
- Arguments:
run_maestro_flow: Run a Maestro YAML flow usingmaestro test.- Arguments:
path
- Arguments: