flutter-toolkit-mcp

cavanaughdesign/flutter-toolkit-mcp

3.2

If you are the rightful owner of flutter-toolkit-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A comprehensive Flutter toolkit Model Context Protocol (MCP) server that provides advanced tools for building Flutter applications.

Tools
  1. flutter_system_info

    Get comprehensive Flutter system information.

  2. generate_flutter_widget

    Generate Flutter widget code from structured input.

  3. create_flutter_database

    Setup databases (SQLite, Hive, Firestore, Supabase, PostgreSQL).

Flutter MCP Server

A comprehensive Flutter toolkit Model Context Protocol (MCP) server that provides advanced tools for building Flutter applications. This server enables AI models and MCP-compatible clients to interact with Flutter development environments, offering system detection, UI tools, widget builders, database management, debugging, analysis, code generation, and batch execution capabilities.


Features

Core Functionality

  • Flutter System Detection: Analyze Flutter SDK installation, devices, and environment
  • MCP Protocol Compliance: Full compatibility with the Model Context Protocol specification
  • TypeScript Implementation: Robust, type-safe server implementation
  • Extensible Architecture: Modular design for easy extension and customization

Available Tools

System Detection Tools
  • flutter_system_info: Get comprehensive Flutter system information
  • flutter_check_installation: Verify Flutter installation status
  • flutter_devices: List all available Flutter devices
  • flutter_doctor: Run Flutter doctor diagnostics
  • analyze_flutter_project: Analyze Flutter project structure and dependencies
  • execute_flutter_command: Execute Flutter CLI commands with error handling
UI & Widget Builder Tools
  • generate_flutter_widget: Generate Flutter widget code from structured input
  • generate_widget_from_description: Generate widgets from natural language descriptions
  • analyze_flutter_ui: Analyze UI code for patterns, complexity, and accessibility
  • suggest_flutter_layout: Get layout suggestions based on UI requirements
  • generate_themed_widget: Generate theme-aware widgets
  • extract_flutter_theme: Extract theme information from existing code
  • generate_responsive_widget: Create responsive widgets for different screen sizes
  • generate_widget_tree_data: Generate widget tree visualization data
Database & Backend Tools
  • create_flutter_database: Setup databases (SQLite, Hive, Firestore, Supabase, PostgreSQL)
  • generate_database_schema: Generate database schemas from model definitions
  • generate_database_migration: Create migration scripts for schema changes
  • generate_crud_operations: Generate CRUD operations for database tables
  • setup_database_connection: Generate database connection and initialization code
  • generate_data_access_layer: Generate complete data access layer with repositories
  • optimize_database: Analyze and optimize database performance
Code Generation & Analysis Tools
  • generate_flutter_tests: Generate unit, widget, or integration tests
  • refactor_flutter_code: Refactor code with extract widget/method, rename, move operations
  • lint_flutter_code: Lint Flutter code with custom rules
  • format_flutter_code: Format Dart/Flutter code according to style guidelines
  • generate_flutter_documentation: Generate API documentation
  • analyze_flutter_code: Run Flutter analyzer to identify issues and improvements
  • generate_code_from_template: Generate code from predefined templates
  • debug_flutter_app: Start debugging sessions with specified configurations
  • analyze_performance: Analyze app performance and identify optimizations
Batch & Parallel Execution Tools
  • execute_batch_operations: Execute multiple Flutter operations in batch with parallel processing
  • run_parallel_analysis: Run parallel analysis on multiple Flutter projects
  • bulk_format_files: Format multiple files using pattern matching
  • run_batch_tests: Run batch tests with parallel execution support

Installation

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn
  • Flutter SDK (for system detection features)

Quick Setup

# Clone or download the project
git clone https://github.com/flutter-mcp-server/flutter-mcp-server.git
cd flutter-mcp-server

# Install dependencies
npm install

# Build the project
npm run build

# Test the server (optional)
npm start

MCP Client Configuration

The Flutter MCP Server can be integrated with any MCP-compatible client. Below are specific configuration examples for popular clients:

Claude Desktop

Configuration Location: %APPDATA%\Claude\claude_desktop_config.json (Windows) or ~/Library/Application Support/Claude/claude_desktop_config.json (macOS)

{
  "mcpServers": {
    "flutter-mcp-server": {
      "command": "node",
      "args": ["C:\\path\\to\\flutter-mcp-server\\dist\\main.js"],
      "env": {
        "FLUTTER_ROOT": "C:\\flutter",
        "ANDROID_HOME": "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk"
      },
      "disabled": false,
      "alwaysAllow": []
    }
  }
}

Windsurf

Configuration Location: Windsurf Settings → MCP Servers

{
  "mcpServers": {
    "flutter-toolkit": {
      "command": "node",
      "args": ["C:\\path\\to\\flutter-mcp-server\\dist\\main.js"],
      "env": {
        "FLUTTER_ROOT": "C:\\flutter",
        "PUB_CACHE": "C:\\Users\\%USERNAME%\\AppData\\Local\\Pub\\Cache"
      },
      "disabled": false,
      "alwaysAllow": ["flutter_system_info", "flutter_devices", "analyze_flutter_project"]
    }
  }
}

Roo Code

Configuration Location: Roo Code → Settings → MCP Configuration

{
  "mcpServers": {
    "flutter": {
      "command": "node",
      "args": ["C:\\Users\\%USERNAME%\\AppData\\Roaming\\Roo-Code\\MCP\\flutter-mcp-server\\dist\\main.js"],
      "env": {
        "FLUTTER_ROOT": "C:\\flutter",
        "ANDROID_HOME": "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk",
        "ANDROID_SDK_ROOT": "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk"
      },
      "disabled": false,
      "alwaysAllow": ["flutter_system_info", "flutter_check_installation", "flutter_doctor"]
    }
  }
}

Cursor AI (VS Code Extension)

Configuration Location: VS Code Settings → Extensions → Cursor AI → MCP Servers

{
  "cursor.mcp.servers": {
    "flutter-mcp": {
      "command": "node",
      "args": ["C:\\path\\to\\flutter-mcp-server\\dist\\main.js"],
      "env": {
        "FLUTTER_ROOT": "C:\\flutter",
        "PUB_CACHE": "C:\\Users\\%USERNAME%\\AppData\\Local\\Pub\\Cache"
      },
      "cwd": "C:\\path\\to\\flutter-mcp-server"
    }
  }
}

Continue (VS Code Extension)

Configuration Location: .continue/config.json in your workspace

{
  "mcpServers": [
    {
      "name": "flutter-mcp-server",
      "command": "node",
      "args": ["C:\\path\\to\\flutter-mcp-server\\dist\\main.js"],
      "env": {
        "FLUTTER_ROOT": "C:\\flutter",
        "ANDROID_HOME": "C:\\Users\\%USERNAME%\\AppData\\Local\\Android\\Sdk"
      }
    }
  ]
}

Generic MCP Client Configuration

For any MCP-compatible client, use this template:

{
  "name": "flutter-mcp-server",
  "command": "node",
  "args": ["<PATH_TO_FLUTTER_MCP_SERVER>/dist/main.js"],
  "env": {
    "FLUTTER_ROOT": "<PATH_TO_FLUTTER_SDK>",
    "ANDROID_HOME": "<PATH_TO_ANDROID_SDK>",
    "PUB_CACHE": "<PATH_TO_PUB_CACHE>"
  }
}

Environment Variables

Configure these environment variables for optimal functionality:

VariableDescriptionExample (Windows)Example (macOS/Linux)
FLUTTER_ROOTFlutter SDK installation pathC:\flutter/usr/local/flutter
ANDROID_HOMEAndroid SDK pathC:\Users\%USERNAME%\AppData\Local\Android\Sdk~/Android/Sdk
ANDROID_SDK_ROOTAlternative Android SDK pathC:\Users\%USERNAME%\AppData\Local\Android\Sdk~/Android/Sdk
PUB_CACHEPub package cache directoryC:\Users\%USERNAME%\AppData\Local\Pub\Cache~/.pub-cache

Usage

Tool Examples

Get System Information
{
  "tool": "flutter_system_info",
  "arguments": {
    "forceRefresh": false
  }
}
Generate Widget from Description
{
  "tool": "generate_widget_from_description",
  "arguments": {
    "description": "A blue elevated button with white text that says 'Submit' and shows a loading spinner when pressed"
  }
}
Create Database Setup
{
  "tool": "create_flutter_database",
  "arguments": {
    "config": {
      "type": "sqlite",
      "name": "app_database",
      "path": "./lib/database/"
    }
  }
}
Run Batch Analysis
{
  "tool": "run_parallel_analysis",
  "arguments": {
    "projectPaths": ["/path/to/project1", "/path/to/project2"],
    "analysisType": "code"
  }
}

Architecture

Core Components

  • MCP Core: Handles MCP protocol communication
  • Tool Manager: Manages tool registration and execution
  • System Detector: Gathers Flutter environment information
  • UI Tools: Widget generation and analysis capabilities
  • Database Tools: Database setup and management
  • Analysis Tools: Code analysis, debugging, and generation
  • Batch Tools: Parallel and batch execution capabilities

Project Structure

src/
ā”œā”€ā”€ server.ts          # Main MCP server implementation
ā”œā”€ā”€ flutter-detector.ts # Flutter system detection
ā”œā”€ā”€ ui-tools.ts        # UI and widget tools
ā”œā”€ā”€ database-tools.ts  # Database management tools
ā”œā”€ā”€ analysis-tools.ts  # Code analysis and generation
ā”œā”€ā”€ batch-tools.ts     # Batch and parallel execution
ā”œā”€ā”€ utils/             # Utility functions and helpers
ā”œā”€ā”€ types/             # TypeScript type definitions
└── index.ts           # Type exports and main entry point

Troubleshooting

Common Issues

  1. "Flutter not found": Ensure FLUTTER_ROOT environment variable is set correctly
  2. "Permission denied": Run chmod +x dist/main.js on Unix systems
  3. "Module not found": Run npm install and npm run build
  4. "Port already in use": Check if another MCP server is running

Debug Mode

Run the server in debug mode for detailed logging:

npm run dev

Error Handling

  • Graceful degradation when Flutter SDK is not available
  • Timeout handling for long-running commands
  • Detailed error messages and suggestions
  • Fallback mechanisms for different Flutter versions
  • Comprehensive input validation for all tools

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

MIT License - see LICENSE file for details.


Support

For issues and questions:

  1. Check the documentation
  2. Review existing issues
  3. Create a new issue with detailed information

Current Status

āœ… ALL FEATURES IMPLEMENTED AND READY FOR PRODUCTION USE

  • āœ… Core MCP server implementation
  • āœ… Flutter system detection and analysis
  • āœ… Complete UI tools and widget builder
  • āœ… Full database creation and management
  • āœ… Comprehensive debugging and analysis tools
  • āœ… Advanced code generation capabilities
  • āœ… Batch and parallel execution tools
  • āœ… Error handling and logging
  • āœ… Type-safe TypeScript implementation
  • āœ… 40+ fully functional tools available

The Flutter MCP Server is production-ready with all advertised features fully implemented and working.