DF

dhruvanbhalara/flutter_agent_lens

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

50 stars 4 forks 质量 73 趋势 14MIT

以代理为先的模型上下文协议(MCP)服务器,用于调试、分析和优化运行中的Flutter应用。

概览

一台模型上下文协议(MCP)服务器,连接 AI 助手与运行中的 Flutter 应用。它通过 WebSockets 与 Dart VM 服务通信,使 AI 工具能够直接访问应用状态、性能数据、布局约束和控制台日志。 AI 助手(如 Claude 或 Copilot)可以检查、分析并调试任何在调试或配置文件模式下运行的 Flutter 应用程序。你可以利用该服务器进行:- 跟踪控件重建频率。- 诊断渲染瓶颈和帧卡顿。- 分析 CPU 使用率和执行热点。- 审计内存使用情况,寻找导致内存泄漏的保留路径。- 捕获控制台、标准配置、存储和日志流。- 读取本地构建大小以定位负载较大的包和资源。- 验证应用链接和通用链接配置。- 驱动滚动行为并触发热重载。 全局激活该包以注册flutter-agent-lens二进制: 确保你的全局pub缓存箱目录在系统PATH中。

概述(AI 翻译)

一台模型上下文协议(MCP)服务器,连接 AI 助手与运行中的 Flutter 应用。它通过 WebSockets 与 Dart VM 服务通信,使 AI 工具能够直接访问应用状态、性能数据、布局约束和控制台日志。


特色

AI 助手(如 Claude 或 Copilot)可以检查、分析和调试任何运行在调试或配置文件模式下运行的 Flutter 应用程序。您可以使用该服务器:

  • 跟踪小部件重建频率。
  • 诊断渲染瓶颈和帧卡顿。
  • 分析CPU使用率和执行热点。
  • 审计内存使用情况,寻找导致内存泄漏的保留路径。
  • 捕获控制台、标准、记录和日志流。
  • 读取本地构建大小以定位重型包和资产。
  • 验证应用链接和通用链接配置。
  • 驱动滚动行为和触发热装填。

布置

1.安装CLI

全局激活该包以注册flutter-agent-lens二进制:

确保你的全局pub缓存bin目录在你的系统路径中。

2.配置MCP客户端

克劳德桌面

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

Flutter Agent Lens MCP Server

A Model Context Protocol (MCP) server that connects AI assistants to running Flutter applications. It communicates with the Dart VM Service over WebSockets, giving AI tools direct access to application state, performance data, layout constraints, and console logs.


Features

AI assistants (such as Claude or Copilot) can inspect, profile, and debug any Flutter application running in debug or profile mode. You can use this server to:

  • Track widget rebuild frequencies.
  • Diagnose rendering bottlenecks and frame jank.
  • Analyze CPU usage and execution hotspots.
  • Audit memory usage and find retaining paths that cause memory leaks.
  • Capture console, stdout, stderr, and logging streams.
  • Read local build sizes to locate heavy packages and assets.
  • Validate App Links and Universal Links configurations.
  • Resolve package: URIs to local source files for precise navigation.
  • Discover and trigger registered service extension RPCs.
  • Drive scroll behaviors and trigger hot reloads.

Setup

1. Install the CLI

Activate the package globally to register the flutter-agent-lens binary:

dart pub global activate flutter_agent_lens

Make sure your global pub cache bin directory is in your system PATH.

2. Configure the MCP Client

Claude Desktop

Add this to your configuration file (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json, Windows: %APPDATA%\Claude\claude_desktop_config.json):

{
  "mcpServers": {
    "flutter_agent_lens": {
      "command": "flutter-agent-lens"
    }
  }
}

Cursor

  1. Go to Settings > Features > MCP.
  2. Click + Add New MCP Server and set:
    • Name: flutter_agent_lens
    • Type: command
    • Command: flutter-agent-lens

Tool Catalog

This server groups functions into action-based tools to keep the schema footprint small.

Connection & Setup (Pre-connection / Startup)

Tool Action Option Description
connection connect``connect_dtd``disconnect Connect to the VM Service, Dart Tooling Daemon (DTD), or disconnect.
discover_apps N/A Find running Flutter apps on this machine.
diagnose_project bundle_size``deep_links Run local build size analysis or check platform deep links.
set_response_format N/A Choose output format (markdown or json).

Connected Tools (Requires Active Connection)

Category Tool Actions / Subcommands Description
App Info get_app_info N/A Get VM version details, isolates, and service extensions.
DTD Integration get_active_location N/A Find active editor path and cursor line (requires DTD).
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "flutter_agent_lens": { "command": "flutter-agent-lens" } } }