Flutter Inspector MCP Server
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Integrations
Interfaces with Dart VM Service Protocol to access Flutter/Dart process information, retrieve version details, and monitor various event streams for debugging Flutter applications.
Connects to a Flutter app's debug mode to extract data about widget trees, render trees, layer trees, and semantics, enabling AI tools to provide context-aware assistance for Flutter app development.
Flutter Inspector MCP Server for AI-Powered Development
š A powerful Model Context Protocol (MCP) server that connects your Flutter apps with AI coding assistants like Cursor, Claude, and Cline.
This project is a work in progress and not all methods (mostly Flutter Inspector related) are implemented yet.
However, two methods are tested with Flutter:
- screenshot
- get_root_widget
Currently Flutter works with MCP server via forwarding server. Please see Architecture for more details.
Some of other methods are not tested - they may work or not. Please use with caution. It is possible that the most methods will be removed from the MCP server later to focus solely on Flutter applications and maybe Jaspr.
!!WARNING!!
ALL DUMPS TOOLS ARE VERY HEAVY OPERATION and can easily overload context window of AI agent. Please use them with extreme caution.
š Quick Start
Prerequisites
- Node.js (v14 or later)
- A Flutter app running in debug mode
- One of: Cursor, Claude, or Cline AI assistant
Installation from GitHub
For developers who want to contribute to the project or run the latest version directly from source, follow these steps:
- Clone the repository:Copy
- Install and build dependencies:This command installs all necessary dependencies listed inCopy
package.json
and then builds MCP server and forwarding server. - Start forwarding server:Copy
- Add DevTools Flutter Extension to Flutter App:Copy
- Start your Flutter app in debug mode! Current workaround for security reasons is to run with
--disable-service-auth-codes
. If you know how to fix this, please let me know!Copy - š ļø Add Flutter Inspector to your AI toolNote for Local Development (GitHub Install):If you installed the Flutter Inspector from GitHub and built it locally, you need to adjust the paths in the AI tool configurations to point to your local
build/index.js
file. Refer to the "Installation from GitHub" section for instructions on cloning and building the project.Cline Setup
- Add to your
.cline/config.json
:Copy - Restart Cline
- The Flutter inspector will be automatically available in your conversations
Cursor Setup
- Open Cursor's settings
- Go to the Features tab
- Under "Model Context Protocol", add the server:Copy
- Restart Cursor
- Open Agent Panel (cmd + L on macOS)
- You're ready! Try commands like "analyze my Flutter app's widget tree"
Claude Setup
- Add to your Claude configuration file:Copy
- Restart Claude
- The Flutter inspector tools will be automatically available
- Add to your
šÆ What You Can Do (Hopefully)
- Analyze Widget Trees: Get detailed information about your Flutter app's structure
- Inspect Navigation: See current routes and navigation state
- Debug Layout Issues: Understand widget relationships and properties
š§ Configuration Options
Environment Variables (.env
)
Command Line Arguments
Port Configuration
All Flutter Inspector tools automatically connect to the default Flutter debug port (8181). You only need to specify a port if:
- You're running Flutter on a different port
- You have multiple Flutter instances running
- You've configured a custom debug port
Example usage:
š§ Troubleshooting
- Connection Issues
- Ensure your Flutter app is running in debug mode
- Verify the port matches in both Flutter app and inspector
- Check if the port is not being used by another process
- AI Tool Not Detecting Inspector
- Restart the AI tool after configuration changes
- Verify the configuration JSON syntax
- Check the tool's logs for connection errors
š Available Tools
All tools default to using port 8181 if no port is specified. You can override this by providing a specific port number.
Utility Methods (Not Direct RPC Calls)
These are helper methods that provide additional functionality beyond direct Flutter RPC calls:
get_active_ports
: Lists all Flutter/Dart processes listening on portsget_supported_protocols
: Retrieves supported protocols from a Flutter appget_vm_info
: Gets detailed VM information from a running Flutter appget_extension_rpcs
: Lists all available extension RPCs in the Flutter app
Debug Methods (ext.flutter.debug*)
Direct RPC methods for debugging Flutter applications:
debug_dump_render_tree
: Dumps the render tree structuredebug_dump_layer_tree
: Dumps the layer tree for rendering analysisdebug_dump_semantics_tree
: Dumps the semantics tree for accessibility analysisdebug_paint_baselines_enabled
: Toggles baseline paint debuggingdebug_dump_focus_tree
: Dumps the focus tree for input handling analysis
Inspector Methods (ext.flutter.inspector.*)
Direct RPC methods for inspecting Flutter widget trees and layout:
inspector_screenshot
: Takes a screenshot of the Flutter app
DartIO Methods (ext.dart.io.*)
Direct RPC methods for Dart I/O operations:
dart_io_get_version
: Gets Flutter version information
Method Categories
- Direct RPC Methods
These methods map directly to Flutter's extension RPCs:
- All methods prefixed with
debug_
,inspector_
, ordart_io_
- Each method corresponds to a specific Flutter RPC endpoint
- Parameters and return values match Flutter's specifications
- All methods prefixed with
- Utility Methods
These are helper methods that provide additional functionality:
- Process discovery (
get_active_ports
) - Protocol inspection (
get_supported_protocols
) - VM interaction (
get_vm_info
) - RPC discovery (
get_extension_rpcs
)
- Process discovery (
Method Naming Convention
All methods follow a consistent naming pattern:
- Utility methods: descriptive_name
- Debug methods: debug_*
- Inspector methods: inspector_*
- DartIO methods: dartio*
- Stream methods: stream_*
Each method name indicates its category and functionality, making it easier to understand its purpose and capabilities.
Method Documentation Format
Each method includes:
- Clear description of functionality
- Required and optional parameters
- Return value format
- Category indication (RPC vs Utility)
- Corresponding Flutter RPC endpoint (if applicable)
For detailed implementation instructions, see the "Implementing New RPC Methods" section.
š§ Implementing New RPC Methods
Step-by-Step Guide
- Add RPC Method DefinitionCopy
- Add Tool DefinitionCopy
- Implement HandlerCopy
Implementation Checklist
- Method Definition
- Add to appropriate group in
FlutterRPC
- Use correct
RPCPrefix
- Follow naming convention
- Add to appropriate group in
- Tool Definition
- Add clear description
- Define all parameters
- Mark required parameters
- Add port parameter
- Document parameter types
- Handler Implementation
- Add case in switch statement
- Handle port parameter
- Validate all parameters
- Add error handling
- Use proper types
- Return wrapped response
- Testing
- Verify method works in debug mode
- Test with different parameter values
- Test error cases
- Test with default port
Example Implementation
Common Patterns
- Parameter Validation
- Always validate required parameters
- Use TypeScript types for type safety
- Throw
McpError
with clear messages
- Error Handling
- Use try-catch blocks for async operations
- Verify Flutter debug mode when needed
- Handle connection errors
- Response Wrapping
- Use
wrapResponse
for consistent formatting - Handle both success and error cases
- Format response data appropriately
- Use
- Port Handling
- Use
handlePortParam()
for port management - Default to 8181 if not specified
- Validate port number
- Use
Notes for AI Agents
When implementing methods from todo.yaml:
- Follow the step-by-step guide above
- Use the example implementation as a template
- Ensure all checklist items are completed
- Add proper error handling and parameter validation
- Follow the common patterns section
- Test the implementation thoroughly
For each new method:
- Check the method's group (UI, DartIO, Inspector, etc.)
- Determine required parameters from method name and context
- Implement following the standard patterns
- Add appropriate error handling
- Follow the existing code style
š¤ Contributing
Contributions are welcome! Please feel free to submit pull requests or report issues on the GitHub repository.
š Learn More
- Flutter DevTools Documentation
- Dart VM Service Protocol
- Flutter DevTools RPC Constants (I guess and hope they are correct:))
š License
MIT - Feel free to use in your projects!
Flutter and Dart are trademarks of Google LLC.
You must be authenticated.
A MCP server with simple goal to debug Flutter apps by giving ability to AI coding assistants (Cline, Cursor, Claude etc..) tools to do analysis of widget trees, navigation, and layout issues. See Architecture to understand how it works https://github.com/Arenukvern/mcp_flutter/blob/main/ARCHITECTURE.md