Attention AI Agent: This guide outlines the process for installing the MCP Flutter Inspector server. Your primary role is to:
- Gather Information: First, you must interact with the USER to obtain specific paths and preferences.
- Execute Steps: Once all necessary information is gathered, proceed with the installation steps precisely as described, substituting placeholders with user-provided values.
- Verify: Confirm with the USER that the installation was successful.
Do not proceed with cloning or modification steps until you have confirmed the necessary paths with the USER.
This guide provides step-by-step instructions for AI agents to install and configure the MCP Flutter Inspector server by cloning from GitHub. This tool enables AI assistants to inspect and interact with Flutter applications during development.
Before starting the installation, ensure the following requirements are met:
- Flutter SDK: Installed and configured (includes Dart SDK)
- Flutter App: Running in debug mode (the USER will specify which app).
- AI Assistant: Cursor, Claude, Cline AI, Windsurf, RooCode, or any MCP-compatible tool
- Git: For cloning the repository
AI Agent: Before proceeding, you must ask the USER the following:
- "Where on your system should I clone the
mcp_flutterrepository? Please provide the absolute path to the directory where you keep your MCP server projects." (Let's call this[MCP_SERVER_BASE_PATH]) - "Which Flutter application project should I configure for use with the MCP Flutter Inspector? Please provide the absolute path to this Flutter project." (Let's call this
[FLUTTER_APP_PATH])
Do not proceed until you have these paths from the USER.
AI Agent: Use the [MCP_SERVER_BASE_PATH] provided by the USER.
cd [MCP_SERVER_BASE_PATH]
git clone https://github.com/Arenukvern/mcp_flutter
cd mcp_flutter # This will be [MCP_SERVER_BASE_PATH]/mcp_flutterLet [CLONED_MCP_FLUTTER_PATH] be [MCP_SERVER_BASE_PATH]/mcp_flutter.
AI Agent: Execute this within [CLONED_MCP_FLUTTER_PATH].
make installThis command will:
- Install all necessary Dart dependencies from
pubspec.yaml - Build the MCP server automatically
- Create the executable at
mcp_server_dart/build/flutter_inspector_mcp
AI Agent: Use the [FLUTTER_APP_PATH] provided by the USER.
cd [FLUTTER_APP_PATH]
flutter pub add mcp_toolkitAlternatively, if the USER prefers, instruct them to manually add to their pubspec.yaml within [FLUTTER_APP_PATH]:
dependencies:
flutter:
sdk: flutter
# ... other dependencies
mcp_toolkit: ^0.4.0Then, AI Agent, run the following within [FLUTTER_APP_PATH]:
flutter pub getAI Agent: Instruct the USER to update their Flutter app's main.dart file located at [FLUTTER_APP_PATH]/lib/main.dart:
import \'package:flutter/material.dart\';
import \'package:mcp_toolkit/mcp_toolkit.dart\';
import \'dart:async\';
Future<void> main() async {
runZonedGuarded(
() async {
WidgetsFlutterBinding.ensureInitialized();
MCPToolkitBinding.instance
..initialize() // Initializes the Toolkit
..initializeFlutterToolkit(); // Adds Flutter related methods to the MCP server
runApp(const MyApp()); // Ensure MyApp is their actual root widget
},
(error, stack) {
// Critical: Handle zone errors for MCP server error reporting
MCPToolkitBinding.instance.handleZoneError(error, stack);
},
);
}
// ... rest of their app codeAI Agent: Remind the USER to replace const MyApp() with their actual root widget if it's different.
AI Agent: Instruct the USER to start their Flutter application (located at [FLUTTER_APP_PATH]) with the following command:
flutter run --debug --host-vmservice-port=8182 --dds-port=8181 --enable-vm-service --disable-service-auth-codesNote to USER (Relay this): The --disable-service-auth-codes flag is currently required as a security workaround.
AI Agent: Ask the USER which AI assistant they are using (Cursor, Cline AI, Claude Desktop, etc.). Based on their answer, provide the corresponding configuration. Use [CLONED_MCP_FLUTTER_PATH] for the path to the server.
-
AI Agent: Instruct the USER that the configuration for MCP servers with Cline AI is typically managed in a file named
cline_mcp_servers.jsonlocated in a specific user configuration directory. The exact path might be~/Library/Application Support/[Cursor | VSCode or other IDE]/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.jsonon macOS (as per the USER's OS). The USER should verify the correct path for their Cline AI installation or consult more detailed Cline documentation.The settings file may have other MCP servers already configured, so you would read it first and then add your new server to the existing
mcpServersobject.
{
"mcpServers": {
"flutter-inspector": {
"command": "[CLONED_MCP_FLUTTER_PATH]/mcp_server_dart/build/flutter_inspector_mcp",
"args": [
"--dart-vm-host=localhost",
"--dart-vm-port=8181",
"--resources",
"--images",
"--dynamics"
],
"env": {},
"disabled": false,
"autoApprove": []
}
}
}- AI Agent: Instruct the USER to restart Cline.
- Flutter inspector tools will be automatically available.
--no-resources.
-
AI Agent: Instruct the USER that the configuration for MCP servers with Cursor AI is typically managed in a file named
~/.cursor/mcp.json.The settings file may have other MCP servers already configured, so you would read it first and then add your new server to the existing
mcpServersobject.
{
"mcpServers": {
"flutter-inspector": {
"command": "[CLONED_MCP_FLUTTER_PATH]/mcp_server_dart/build/flutter_inspector_mcp",
"args": [
"--dart-vm-host=localhost",
"--dart-vm-port=8181",
"--no-resources",
"--images",
"--dynamics"
],
"env": {},
"disabled": false
}
}
}- AI Agent: Instruct the USER to restart Cursor.
- Open Agent Panel (Cmd+L on macOS).
- Test with commands like "List all available tools from my Flutter app" or "Take a screenshot of my app".
- AI Agent: Instruct the USER to add to their Claude configuration file (e.g.,
~/Library/Application Support/Claude/claude_desktop_config.jsonon macOS; confirm path with user if different):
{
"mcpServers": {
"flutter-inspector": {
"command": "[CLONED_MCP_FLUTTER_PATH]/mcp_server_dart/build/flutter_inspector_mcp",
"args": [
"--dart-vm-host=localhost",
"--dart-vm-port=8181",
"--resources",
"--images",
"--dynamics"
],
"env": {},
"disabled": false
}
}
}- AI Agent: Instruct the USER to restart Claude Desktop.
- Flutter inspector tools will be automatically available.
AI Agent: Inform the USER about the new dynamic tools registration feature:
The v2.2.0 release introduces the ability for Flutter apps to register custom tools and resources at runtime. This means:
- Tools can be added while the app is running. However MCP Server may need to be restarted to see the new tools.
- Hot Reload Support: Tools update automatically during development
- Custom Functionality: Apps can expose app-specific debugging and inspection tools
AI Agent: Show the USER how to register a custom tool in their Flutter app:
// Add this to your Flutter app after MCPToolkitBinding initialization
final customTool = MCPCallEntry.tool(
handler: (request) {
final name = request['name'] ?? 'World';
return MCPCallResult(
message: 'Hello, $name!',
parameters: {'greeting': 'Hello, $name!'},
);
},
definition: MCPToolDefinition(
name: 'say_hello',
description: 'Say hello to someone',
inputSchema: {
'type': 'object',
'properties': {
'name': {
'type': 'string',
'description': 'Name to greet',
},
},
},
),
);
// Register the tool
await MCPToolkitBinding.instance.addEntries(entries: {customTool});AI Agent: Explain to the USER how to use dynamic tools:
- Discover Tools: Use
listClientToolsAndResourcesto see all available tools - Execute Tools: Use
runClientToolwith the tool name and parameters - Hot Reload: Tools update automatically when you hot reload your Flutter app
AI Agent: To verify with the USER that the installation is successful:
- Confirm their Flutter app (from
[FLUTTER_APP_PATH]) is running with the specified flags. - Confirm their AI assistant has been restarted after configuration.
- Ask them to try commands like:
- "List all available tools from my Flutter app"
- "Take a screenshot of the app"
- "Get runtime errors"
- Path Configuration: Ensure all paths like
[CLONED_MCP_FLUTTER_PATH]and[FLUTTER_APP_PATH]were correctly substituted with your actual absolute paths. - Security: The
--disable-service-auth-codesflag is a temporary workaround. - Debug Mode: The Flutter app must be running in debug mode for the inspector to work.
- Port Configuration: Default ports used by the Flutter app are 8182 (VM service) and 8181 (DDS).
- Dynamic Tools: The
--dynamicsflag enables dynamic tools registration support.
- Connection Issues:
- Verify Flutter app is running with correct flags and ports (
--host-vmservice-port=8182 --dds-port=8181). - Check AI tool's MCP server configuration for correct command and arguments.
- Verify Flutter app is running with correct flags and ports (
- MCP Server Not Found:
- Double-check that
[CLONED_MCP_FLUTTER_PATH]/mcp_server_dart/build/flutter_inspector_mcpis the correct and absolute path to the built server executable. - Ensure
make installin Step 3 completed successfully and created thebuilddirectory.
- Double-check that
- Permission Errors:
- Check file permissions for
[CLONED_MCP_FLUTTER_PATH]and its subdirectories. - Ensure the
flutter_inspector_mcpexecutable has execute permissions.
- Check file permissions for
- Tool Not Available in AI Assistant:
- Ensure the AI assistant was restarted after its MCP configuration was updated.
- Verify the
disabled: falseflag in the MCP server configuration for the AI tool.
- Dynamic Tools Not Appearing:
- Ensure
mcp_toolkitpackage is properly initialized in your Flutter app. - Check that tools are registered using
MCPToolkitBinding.instance.addEntries(). - Use
listClientToolsAndResourcesto verify registration. - Hot reload your Flutter app after adding new tools.
- Ensure
The Dart-based MCP server supports the following command-line options:
--dart-vm-host: Host for Dart VM connection (default: localhost)--dart-vm-port: Port for Dart VM connection (default: 8181)--resources: Enable resources support (default: true)--no-resources: Disable resources support (useful for Cursor)--images: Enable images support (default: true)--dumps: Enable dumps support (default: false)--dynamics: Enable dynamic tools registration (default: true)--log-level: Logging level (default: info)--environment: Environment (default: production)