This guide walks you through setting up the MCP Flutter toolkit to enable AI assistants to interact with Flutter applications.
MCP Flutter provides a bridge between AI assistants and Flutter applications through the Model Context Protocol (MCP). The system uses Flutter's native service extension mechanism to enable real-time communication and dynamic tools registration for registering client side (Flutter App) tools and resources.
Architecture: AI Assistant ↔ MCP Server (Dart) ↔ Dart VM ↔ Flutter Service Extensions
- Flutter SDK (3.0.0 or later)
- Dart SDK (included with Flutter)
- A Flutter app running in debug mode
- One of: Cursor, Claude, Cline AI, Windsurf, RooCode, or any other AI assistant that supports MCP server
- using Cursor: https://www.youtube.com/watch?v=pyDHaI81uts
- using VSCode + Cline: (Soon)
For developers who want to contribute to the project or run the latest version directly from source, follow these steps:
-
Clone the repository:
git clone https://github.com/Arenukvern/mcp_flutter cd mcp_flutter -
Install and build dependencies:
make install
This command installs all necessary dependencies listed in
pubspec.yamland then builds the MCP server. -
Add
mcp_toolkitPackage to Your Flutter App:The
mcp_toolkitpackage provides the necessary service extensions within your Flutter application. You need to add it to your app'spubspec.yaml.Run this command in your Flutter app's directory to add the
mcp_toolkitpackage:flutter pub add mcp_toolkit
or add it to your
pubspec.yamlmanually:dependencies: flutter: sdk: flutter # ... other dependencies mcp_toolkit: ^0.4.0 # Use the latest version
Then run
flutter pub getin your Flutter app's directory. -
Initialize in Your App: In your Flutter application's
main.dartfile (or equivalent entry point), initialize the bridge binding:import 'package:flutter/material.dart'; import 'package:mcp_toolkit/mcp_toolkit.dart'; // Import the package 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()); }, (error, stack) { // You can place it in your error handling tool, or directly in the zone. The most important thing is to have it - otherwise the errors will not be captured and MCP server will not return error results. MCPToolkitBinding.instance.handleZoneError(error, stack); }, ); } // ... rest of your app code
-
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!flutter run --debug --host-vmservice-port=8182 --dds-port=8181 --enable-vm-service --disable-service-auth-codes
-
🛠️ Add Flutter Inspector to your AI tool
Note 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/flutter_inspector_mcpfile. Refer to the "Installation from GitHub" section for instructions on cloning and building the project.Note: please use
--no-resourcesflag to disable resources support - for unknown reason it doesn't work with Cline.- Add to your
.cline/config.json:{ "mcpServers": { "flutter-inspector": { "command": "/path/to/your/cloned/mcp_flutter/mcp_server_dart/build/flutter_inspector_mcp", "args": [ "--dart-vm-host=localhost", "--dart-vm-port=8181", "--no-resources", "--images" ], "env": {}, "disabled": false, "autoApprove": [] } } } - Restart Cline
- The Flutter inspector will be automatically available in your conversations
- You're ready! Try commands like "Please get screenshot of my app" or "List all available tools from my Flutter app"
- Since Cursor doesn't support resources, you need to pass
--no-resourcesas an argument. It will make all resources to be displayed as tools instead.
You can use this badge to add Flutter Inspector to Cursor:
Note: fix path after installation.
- Open Cursor's settings
- Go to the Features tab
- Under "Model Context Protocol", add the server:
{ "mcpServers": { "flutter-inspector": { "command": "/path/to/your/cloned/mcp_flutter/mcp_server_dart/build/flutter_inspector_mcp", "args": [ "--dart-vm-host=localhost", "--dart-vm-port=8181", "--no-resources", "--images" ], "env": {}, "disabled": false } } } - Restart Cursor
- Open Agent Panel (cmd + L on macOS)
- You're ready! Try commands like "List all available tools from my Flutter app" or "Take a screenshot of my app"
- Add to your Claude configuration file:
{ "mcpServers": { "flutter-inspector": { "command": "/path/to/your/cloned/mcp_flutter/mcp_server_dart/build/flutter_inspector_mcp", "args": [ "--dart-vm-host=localhost", "--dart-vm-port=8181", "--resources", "--images" ], "env": {}, "disabled": false } } } - Restart Claude
- The Flutter inspector tools will be automatically available
- You're ready! Try commands like "Show me all tools available in my Flutter app"
Note: It seems that RooCode doesn't support images in MCP server responses as it was earlier with Cline and Cursor. So as a workaround you can use
--save-imagesflag to save images to files.Note: Also, please use
--no-resourcesflag to disable resources support - for unknown reason it doesn't work with RooCode.- Add to your RooCode configuration file:
{ "mcpServers": { "flutter-inspector": { "command": "/path/to/your/cloned/mcp_flutter/mcp_server_dart/build/flutter_inspector_mcp", "args": [ "--dart-vm-host=localhost", "--dart-vm-port=8181", "--no-resources", "--images", "--save-images" ], "env": {}, "disabled": false } } } - Add to your
One of the key features of v2.2.0 is the ability to register custom tools and resources from your Flutter app at runtime:
import 'package:mcp_toolkit/mcp_toolkit.dart';
import 'package:dart_mcp/client.dart';
// Register a custom tool in your Flutter App (!).
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: ObjectSchema(
required: ['name'],
properties: {
'name': StringSchema(
description: 'Name to greet',
),
},
),
),
);
// Register the tool
await MCPToolkitBinding.instance.addEntries(entries: {customTool});The tools should be registered automatically in MCP server. However, since most clients doesn't support tools/change feature, you have two options:
- Reload MCP server (from interface).
- Use
listClientToolsAndResourcesto see all available tools and resources and then callrunClientToolorrunClientResourceto execute them.
To install Flutter Inspector for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @Arenukvern/mcp_flutter --client claude