Back to MCP directory
publicPublicdnsLocal runtime

flutter-tools

Flutter工具MCP服务器,提供Dart/Flutter文件的分析与修复功能。

article

README

🚀 Flutter 工具 MCP 服务器

flutter-tools MCP 服务器提供了与 Flutter SDK 交互的工具,主要包含 get_diagnosticsapply_fixes 两个工具,可用于分析和修复 Dart/Flutter 文件。

🚀 快速开始

  1. 确保 Flutter SDK 已安装并添加到 PATH。
  2. 使用配置命令启动 MCP 服务器。
  3. 根据需要使用 get_diagnosticsapply_fixes 工具。

✨ 主要特性

  • 提供 get_diagnostics 工具,可获取 Dart/Flutter 文件的诊断信息。
  • 提供 apply_fixes 工具,能应用 Dart 文件的修复建议。

📦 安装指南

要安装 MCP 服务器,请将以下配置添加到您的 MCP 设置文件中:

{
  "mcpServers": {
    "flutter-tools": {
      "command": "node",
      "args": ["/path/to/flutter-tools/build/index.js"],
      "env": {}
    }
  }
}

请将 /path/to/flutter-tools/build/index.js 替换为您实际的编译后 JavaScript 文件路径。

💻 使用示例

基础用法

get_diagnostics

描述:获取 Dart/Flutter 文件的诊断信息。 输入方案

{
  "type": "object",
  "properties": {
    "file": {
      "type": "string",
      "description": "Dart/Flutter 文件路径"
    }
  },
  "required": ["file"]
}

示例用法

{
  "name": "get_diagnostics",
  "arguments": {
    "file": "/path/to/your/file.dart"
  }
}

apply_fixes

描述:应用 Dart 文件的修复建议。 输入方案

{
  "type": "object",
  "properties": {
    "file": {
      "type": "string",
      "description": "Dart/Flutter 文件路径"
    }
  },
  "required": ["file"]
}

示例用法

{
  "name": "apply_fixes",
  "arguments": {
    "file": "/path/to/your/file.dart"
  }
}

🔧 技术细节

依赖项

  • @modelcontextprotocol/sdk: ^1.0.0
  • node-pty: ^1.0.0
  • which: ^4.0.0

开发依赖项

  • @types/node: ^18.19.0
  • @types/which: ^3.0.3
  • typescript: ^5.3.3

脚本

  • build:编译 TypeScript 代码并设置可执行权限。
  • prepare:运行 build 脚本。
  • watch:监控文件变化并自动重新编译。
help

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client