Flutter MCP Service is an advanced development tool that enhances Flutter development through the Model Context Protocol (MCP). It provides intelligent caching, token management, and seamless integration with official Flutter documentation to help streamline your development workflow.
# Clone the repository
git clone https://github.com/dvillegastech/flutter_mcp_2.git
cd flutter_mcp_service
# Install dependencies
npm install
# Initialize cache
mkdir -p .cache
# Run health check
npm run health-check
# Start service
npm start
Add to your MCP configuration file:
{
"mcpServers": {
"flutter-mcp": {
"command": "node",
"args": ["/absolute/path/to/flutter_mcp_service/src/index.js"]
}
}
}
Check service health and cache statistics.
@flutter-mcp use flutter_status to check service health
Universal search across Flutter/Dart documentation, packages, and examples.
@flutter-mcp use flutter_search with query "Container" and limit 5
@flutter-mcp use flutter_search to find ListView examples
Parameters:
query
(required): Search termlimit
(optional): Max results (default: 10)maxTokens
(optional): Response size limit (default: 4000)Smart Flutter documentation fetcher and code analyzer.
@flutter-mcp use flutter_analyze with identifier "Container"
@flutter-mcp use flutter_analyze with identifier "Container" and this code:
Container(
width: 100,
height: 100,
color: Colors.blue,
)
Parameters:
identifier
(required): Widget/class name or packagecode
(optional): Code to analyzetopic
(optional): "all", "docs", "analysis", "examples" (default: "all")maxTokens
(optional): Response size limitincludeExamples
(optional): Include code examples (default: true)includeAnalysis
(optional): Include code analysis (default: true)Analyze Flutter widget code for best practices, performance, and accessibility.
@flutter-mcp use analyze_widget with this widgetCode:
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
child: Text('Hello World'),
);
}
}
Parameters:
widgetCode
(required): Flutter widget codecheckAccessibility
(optional): Check accessibility (default: true)checkPerformance
(optional): Check performance (default: true)Validate code against official Flutter documentation.
@flutter-mcp use validate_flutter_docs with this code:
Container(
color: Colors.red,
decoration: BoxDecoration(color: Colors.blue), // This will be flagged
)
Parameters:
code
(required): Flutter/Dart codewidgetType
(optional): Specific widget to focus onAnalyze packages from pub.dev for quality and compatibility.
@flutter-mcp use analyze_pub_package with packageName "provider"
@flutter-mcp use analyze_pub_package with packageName "dio" and checkDependencies true
Parameters:
packageName
(required): Package name from pub.devcheckDependencies
(optional): Analyze dependencies (default: true)checkScores
(optional): Retrieve pub.dev scores (default: true)Get improvement suggestions based on Flutter best practices.
@flutter-mcp use suggest_improvements for this code:
ListView(
children: List.generate(1000, (i) => Text('Item $i')),
)
Parameters:
code
(required): Flutter codefocusArea
(optional): "performance", "accessibility", "maintainability", "all"Analyze Flutter widget tree for performance issues.
@flutter-mcp use analyze_performance with this widgetTree:
Column(
children: [
for (int i = 0; i < 100; i++)
Container(child: Text('Item $i')),
],
)
Parameters:
widgetTree
(required): Widget tree codecheckRebuildOptimization
(optional): Check rebuilds (default: true)checkMemoryLeaks
(optional): Check memory leaks (default: true)Analyze project architecture compliance.
@flutter-mcp use analyze_architecture with projectStructure {
"lib": {
"features": ["auth", "home", "profile"],
"core": ["network", "database"],
"shared": ["widgets", "utils"]
}
} and pattern "clean"
Parameters:
projectStructure
(required): Project directory structurepattern
(optional): "clean", "mvvm", "mvc", "auto"checkDependencies
(optional): Check dependency violations (default: true)Analyze app bundle size with optimization recommendations.
@flutter-mcp use analyze_bundle_size with buildPath "/path/to/build" and platform "android"
Parameters:
buildPath
(required): Path to build outputplatform
(optional): "android", "ios", "web", "all"includeAssets
(optional): Include asset analysis (default: true)Generate comprehensive Flutter tests.
@flutter-mcp use generate_tests for this widgetCode:
class CounterButton extends StatelessWidget {
final VoidCallback onPressed;
final int count;
const CounterButton({required this.onPressed, required this.count});
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: onPressed,
child: Text('Count: $count'),
);
}
}
Parameters:
widgetCode
(required): Widget codetestType
(optional): "unit", "widget", "integration", "golden", "all"includeAccessibility
(optional): Include accessibility tests (default: true)Trace state flow and rebuilds in Flutter widgets.
@flutter-mcp use trace_state with this widgetCode:
class MyStatefulWidget extends StatefulWidget {
// ... widget code
}
Parameters:
widgetCode
(required): Widget codetraceRebuildPaths
(optional): Trace rebuilds (default: true)generateVisualization
(optional): Generate visualization (default: true)Generate Clean Architecture structure.
@flutter-mcp use generate_clean_architecture with projectName "todo_app" and features ["auth", "todos", "settings"]
Parameters:
projectName
(required): Project/feature namefeatures
(required): List of featuresstateManagement
(optional): "riverpod", "bloc", "provider", "getx"includeDI
(optional): Include dependency injection (default: true)Generate localization setup with ARB files.
@flutter-mcp use generate_l10n with languages ["en", "es", "fr"]
Parameters:
languages
(required): Language codes to supporttranslations
(optional): Initial translationsincludeRTL
(optional): Include RTL support (default: true)includePluralization
(optional): Include pluralization (default: true)Generate performance monitoring setup.
@flutter-mcp use monitor_performance with monitoringType "balanced"
Parameters:
monitoringType
(required): "comprehensive", "balanced", "lightweight"includeNetwork
(optional): Monitor network (default: true)includeMemory
(optional): Monitor memory (default: true)includeAnalytics
(optional): Include analytics (default: true)Diagnose and fix rendering issues.
@flutter-mcp use diagnose_render_issues with this widgetCode:
Row(
children: [
Expanded(child: Text('Long text')),
Container(width: double.infinity), // This will cause issues
],
)
Parameters:
widgetCode
(required): Widget code with issueserrorType
(optional): "overflow", "constraint", "layout", "all"includeVisualization
(optional): Include debug visualization (default: true)Analyze test coverage with recommendations.
@flutter-mcp use analyze_test_coverage with coverageData {...} and targetCoverage 80
Parameters:
coverageData
(required): Coverage data from lcovprojectStructure
(required): Project file structuretargetCoverage
(optional): Target percentage (default: 80)generateReport
(optional): Generate visual report (default: true)@flutter-mcp analyze this Flutter widget for issues:
Container(
child: Column(
children: List.generate(100, (i) => Text('Item $i')),
),
)
@flutter-mcp search for "state management" packages and analyze the top result
1. @flutter-mcp analyze_performance for my widget tree
2. @flutter-mcp suggest_improvements based on performance issues
3. @flutter-mcp generate_tests for the optimized code
@flutter-mcp analyze_architecture for my project and suggest clean architecture improvements
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "flutter-mcp" '{"command":"node","args":["/absolute/path/to/flutter_mcp_service/src/index.js"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"flutter-mcp": {
"command": "node",
"args": [
"/absolute/path/to/flutter_mcp_service/src/index.js"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"flutter-mcp": {
"command": "node",
"args": [
"/absolute/path/to/flutter_mcp_service/src/index.js"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect