A comprehensive toolset for Flutter development with AI assistant integration through the Model Context Protocol.
This project provides a powerful platform for interacting with Flutter applications programmatically, enabling AI assistants and development tools to inspect, control, and optimize Flutter apps. The system follows a two-component architecture that provides scalability and robustness.
The project consists of two main components:
-
Flutter Connector Server: A standalone server that monitors Flutter applications, providing direct access to their state, logs, performance metrics, and more.
-
MCP Server: A Model Context Protocol server that provides AI assistants with tools to interact with Flutter applications through a standardized interface.
These components work together to provide a seamless experience for debugging, testing, and analyzing Flutter applications.
┌──────────────────┐ ┌───────────────────┐ ┌─────────────────┐
│ │ │ │ │ │
│ AI Assistant │◄─────────┤ MCP Server │◄─────────┤ Flutter │
│ (Claude, etc.) │ MCP │ (Tool Provider) │ REST │ Connector │
│ ├─────────►│ ├─────────►│ Server │
└──────────────────┘ └───────────────────┘ └────────┬────────┘
│
│ VM Service
│ Protocol
▼
┌─────────────────┐
│ │
│ Flutter Apps │
│ (Debugging Mode)│
│ │
└─────────────────┘
The system works as follows:
- Flutter Connector Server discovers and connects to Flutter apps in debug mode via the VM Service Protocol
- MCP Server communicates with the Flutter Connector Server via REST API calls
- AI Assistants (like Claude) use the tools provided by the MCP Server through the Model Context Protocol
- This layered approach allows AI tools to analyze, debug, and optimize Flutter applications seamlessly
-
Application Management
- Start/stop Flutter applications
- List running applications
- Hot reload apps
- Monitor app logs
-
Device Management
- Discover connected devices (Android/iOS/simulators/emulators)
- Get device information
- Select the best device based on priority rules
-
Debugging Capabilities
- Take screenshots
- Monitor network traffic
- Collect performance metrics
- Launch Flutter DevTools
- Get widget hierarchies
-
Analytics and Insights
- Collect time-series performance data
- Analyze trends
- Detect anomalies
- Generate optimization recommendations
-
Reliability
- Process monitoring
- Automatic recovery
- Self-healing mechanisms
- Resource usage optimization
- Node.js (v18 or later)
- Flutter SDK
- Android SDK (for Android development)
- Xcode (for iOS development, macOS only)
-
Clone the repository:
git clone https://github.com/yourusername/flutter-tools-mcp.git cd flutter-tools-mcp -
Install dependencies for both components:
# Install MCP server dependencies cd mcp npm install npm run build cd .. # Install Flutter Connector Server dependencies cd flutter-connector-server npm install npm run build cd ..
You need to run both the Flutter Connector Server and the MCP Server:
-
Start the Flutter Connector Server:
cd flutter-connector-server npm startThis will start the connector server on port 5051 by default.
-
Start the MCP Server (in a new terminal):
cd mcp npm startThis will start the MCP server running on stdio, ready to connect to MCP clients.
To use the Flutter Tools MCP with your Flutter applications, follow these steps:
-
Launch your Flutter app in debug mode:
flutter run
-
Note the VM Service URL that appears in the console output. It will look something like:
Connecting to VM Service at ws://127.0.0.1:55285/xxxxxxxxxxxx=/ws -
IMPORTANT: Connect to your Flutter app using the VM Service URL first: This is a crucial step! Before using any other tools, you must first connect to your Flutter app using the
connect-by-urltool with the VM Service URL from step 2.Example:
connect-by-url --vmServiceUrl ws://127.0.0.1:55285/xxxxxxxxxxxx=/ws -
After connecting, you can use all other tools with the app ID returned from the connection step:
get-performance-metrics --appId YOUR_APP_ID get-app-logs --appId YOUR_APP_ID take-screenshot --appId YOUR_APP_ID
To use the Flutter Tools MCP with Claude for Desktop:
-
Open the Claude for Desktop configuration file:
# On macOS nano ~/Library/Application\ Support/Claude/claude_desktop_config.json # On Windows notepad %APPDATA%\Claude\claude_desktop_config.json
-
Add the configuration for the Flutter Tools MCP:
{ "mcpServers": { "flutter-tools": { "command": "node", "args": [ "/ABSOLUTE/PATH/TO/flutter-tools-mcp/mcp/build/index.js" ] } } }Make sure to replace
/ABSOLUTE/PATH/TOwith the actual absolute path to your project directory. -
Save the file and restart Claude for Desktop.
-
You should now see the Flutter tools icon in the Claude for Desktop interface.
-
Remember: Always use the
connect-by-urltool first with your VM Service URL before using any other tools.
To integrate with Cursor:
- Ensure you have Cursor installed with MCP support
- Configure Cursor to use the Flutter Tools MCP:
- Open Cursor settings
- Navigate to the MCP section
- Add a new MCP server with the command:
node /ABSOLUTE/PATH/TO/flutter-tools-mcp/mcp/build/index.js
- Restart Cursor to apply the changes
- Important: When using the Flutter tools in Cursor, always start by connecting to your app with the
connect-by-urltool and the VM Service URL before using any other tools.
The MCP server provides the following tools for AI assistants:
| Tool Name | Description |
|---|---|
connect-by-url |
FIRST STEP: Connect to a Flutter app using the VM Service URL |
list-flutter-apps |
List all running Flutter applications |
connect-to-app |
Connect to a specific Flutter app by ID |
get-app-logs |
Retrieve logs from a connected Flutter app |
get-performance-metrics |
Get performance metrics from a Flutter app |
get-network-requests |
Fetch network request data from a Flutter app |
take-screenshot |
Capture a screenshot of the Flutter app UI |
get-widget-tree |
Retrieve the widget tree structure of a Flutter app |
analyze-performance |
Run a performance analysis on the Flutter app |
GET /api/apps - List running apps
GET /api/apps/{appId} - Get app details
POST /api/apps/from-url - Add an app using VM service URL
GET /api/apps/{appId}/logs - Get app logs
GET /api/apps/{appId}/metrics - Get performance metrics
GET /api/apps/{appId}/network - Get network traffic
GET /api/apps/{appId}/screenshot - Take screenshot
GET /api/apps/{appId}/widget-tree - Get widget tree
GET /api/health - Server health check
flutter-tools-mcp/
├── mcp/ # MCP server
│ ├── src/
│ │ ├── tools/ # Tool implementations
│ │ ├── services/ # Services (connector client, etc.)
│ │ ├── types/ # TypeScript type definitions
│ │ └── index.ts # Main entry point
│ └── package.json
│
├── flutter-connector-server/ # Flutter Connector Server
│ ├── src/
│ │ ├── services/ # Core services
│ │ ├── controllers/ # API controllers
│ │ ├── utils/ # Utility functions
│ │ └── server.ts # Server implementation
│ └── package.json
│
└── README.md # This documentation file
To run the servers with auto-reloading during development:
# MCP Server
cd mcp
npm run dev
# Flutter Connector Server
cd flutter-connector-server
npm run devContributions are welcome! Please feel free to submit pull requests.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.