Flutter MCP Server

Flutter MCP servers enable AI models to interact with Flutter projects, providing capabilities for code analysis, formatting, testing, and documentation retrieval.

April 25, 2025
MCP ServerDevelopment Tools & DevOpsFlutter MCP Server
GitHub starsnpm versionnpm downloads

Overview

The Flutter MCP Server is an open-source implementation of the Model Context Protocol (MCP) for the Dart and Flutter ecosystem. It acts as a bridge between AI assistants, developer tools, and automated workflows, enabling secure, programmable, and context-aware automation of Dart and Flutter development tasks. It provides AI agents with real-time Flutter/Dart documentation and pub.dev package information, helping to generate accurate and up-to-date Flutter code.

Key Features

📚

Real-time Documentation

Provides up-to-date Flutter/Dart documentation and pub.dev package info to AI assistants.

🛠️

SDK Tool Exposure

Exposes Dart & Flutter SDK tools (analyze, format, fix, create, run, test) as programmable endpoints.

🔄

Automated Workflows

Enables AI-driven workflows, automation, and remote development for Dart/Flutter projects.

🐳

Docker Support

Easily build and run in a containerized environment for reproducibility and security.

Available Tools

Quick Reference

ToolPurposeCategory
analyzeAnalyze Dart/Flutter codeCode Analysis
formatFormat Dart/Flutter codeCode Formatting
fixApply automated fixes to Dart/Flutter codeCode Refactoring
createCreate new Flutter projectsProject Management
runRun Flutter applicationsApplication Execution
testRun tests for Flutter projectsTesting
get_app_errorsRetrieves precise and condensed error information from your Flutter appError Monitoring
view_screenshotCaptures screenshots of the running applicationDebugging
get_view_detailsGet details about views in the app (size, pixel ratio)UI Inspection

Detailed Usage

analyze

Analyzes Dart and Flutter code for potential issues and best practices.

use_mcp_tool({
  server_name: "flutter",
  tool_name: "analyze",
  arguments: {
    path: "./lib/main.dart"
  }
});
format

Formats Dart and Flutter code according to style guidelines.

use_mcp_tool({
  server_name: "flutter",
  tool_name: "format",
  arguments: {
    path: "./lib/main.dart"
  }
});
fix

Applies automated fixes to Dart and Flutter code.

use_mcp_tool({
  server_name: "flutter",
  tool_name: "fix",
  arguments: {
    path: "./lib/main.dart"
  }
});
create

Creates a new Flutter project.

use_mcp_tool({
  server_name: "flutter",
  tool_name: "create",
  arguments: {
    projectName: "my_new_app"
  }
});
run

Runs a Flutter application on a connected device or emulator.

use_mcp_tool({
  server_name: "flutter",
  tool_name: "run",
  arguments: {
    deviceId: "emulator-5554"
  }
});
test

Runs tests for a Flutter project.

use_mcp_tool({
  server_name: "flutter",
  tool_name: "test",
  arguments: {
    path: "./test/widget_test.dart"
  }
});
get_app_errors

Retrieves precise and condensed error information from your Flutter app.

use_mcp_tool({
  server_name: "flutter",
  tool_name: "get_app_errors",
  arguments: {}
});
view_screenshot

Captures screenshots of the running application.

use_mcp_tool({
  server_name: "flutter",
  tool_name: "view_screenshot",
  arguments: {
    outputPath: "/tmp/screenshot.png"
  }
});
get_view_details

Get details about views in the app (size, pixel ratio).

use_mcp_tool({
  server_name: "flutter",
  tool_name: "get_view_details",
  arguments: {}
});

Installation

{
  "mcpServers": {
    "flutter-docs": {
      "command": "npx",
      "args": [
        "flutter-mcp"
      ]
    }
  }
}

Common Use Cases

1. AI-powered Code Generation

Enable AI to generate correct and up-to-date Flutter code by providing real-time documentation.

// Example of AI generating Riverpod code with Flutter MCP
// User: "How do I use @flutter_mcp riverpod:^2.5.0 to watch a future?"
// AI generates (using v2.5.1 docs):
// final userProvider = FutureProvider.autoDispose
//   .family<User, String>((ref, userId) async {
//     return ref.watch(apiProvider).fetchUser(userId);
// });

2. Automated Code Review and Refactoring

Automate code analysis, formatting, and application of fixes using AI agents.

use_mcp_tool({
  server_name: "flutter",
  tool_name: "analyze",
  arguments: {
    path: "./lib/my_feature.dart"
  }
});

use_mcp_tool({
  server_name: "flutter",
  tool_name: "fix",
  arguments: {
    path: "./lib/my_feature.dart"
  }
});

3. CI/CD Integration

Integrate Flutter MCP into CI/CD pipelines for automated testing and code quality checks.

use_mcp_tool({
  server_name: "flutter",
  tool_name: "test",
  arguments: {
    path: "./test/"
  }
});

Connection String Format

The Flutter MCP server primarily uses command-line arguments for configuration. For HTTP transport, you can specify the port.

  • HTTP Transport: npx flutter-mcp --transport http --port 8000

Sources