Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 61 additions & 60 deletions pkgs/dart_mcp_server/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,73 +1,74 @@
# 0.1.1 (Dart SDK 3.10.0) - WIP

* Change tools that accept multiple roots to not return immediately on the first
- Change tools that accept multiple roots to not return immediately on the first
failure.
* Add failure reason field to analytics events so we can know why tool calls are
- Add failure reason field to analytics events so we can know why tool calls are
failing.
* Add a flutter_driver command for executing flutter driver commands on a device.
* Allow for multiple package arguments to `pub add` and `pub remove`.
* Require dart_mcp version 0.3.1.
* Add support for the flutter_driver screenshot command.
* Change the widget tree to the full version instead of the summary. The summary
- Add a flutter_driver command for executing flutter driver commands on a device.
- Allow for multiple package arguments to `pub add` and `pub remove`.
- Require dart_mcp version 0.3.1.
- Add support for the flutter_driver screenshot command.
- Change the widget tree to the full version instead of the summary. The summary
tends to hide nested text widgets which makes it difficult to find widgets
based on their text values.
* Add an `--exclude-tool` command line flag to exclude tools by name.
* Add the abillity to limit the output of `analyze_files` to a set of paths.
* Stop reporting non-zero exit codes from command line tools as tool errors.
* Add descriptions for pub tools, add support for `pub deps` and `pub outdated`.
* Fix a bug in hot_reload ([#290](https://github.com/dart-lang/ai/issues/290)).
* Add the `list_devices`, `launch_app`, `get_app_logs`, and `list_running_apps`
- Add an `--exclude-tool` command line flag to exclude tools by name.
- Add the abillity to limit the output of `analyze_files` to a set of paths.
- Stop reporting non-zero exit codes from command line tools as tool errors.
- Add descriptions for pub tools, add support for `pub deps` and `pub outdated`.
- Fix a bug in hot_reload ([#290](https://github.com/dart-lang/ai/issues/290)).
- Add the `list_devices`, `launch_app`, `get_app_logs`, and `list_running_apps`
tools for running Flutter apps.
* Add the `hot_restart` tool for restarting running Flutter apps.
* Add extra log output to failed launches, and allow AI to specify the maxLines
- Add the `hot_restart` tool for restarting running Flutter apps.
- Add extra log output to failed launches, and allow AI to specify the maxLines
of log output.
- Convert `launch_app` to use `--machine` output to capture the DTD URI.

# 0.1.0 (Dart SDK 3.9.0)

* Add documentation/homepage/repository links to pub results.
* Handle relative paths under roots without trailing slashes.
* Fix executable paths for dart/flutter on windows.
* Pass the provided root instead of the resolved root for project type detection.
* Be more flexible about roots by comparing canonicalized paths.
* Create the working dir if it doesn't exist.
* Add the --platform and --empty arguments to the flutter create tool.
* Invoke dart/flutter in a more robust way.
* Remove qualifiedNames from the pub dev api search.
* Flutter/Dart create tool.
* Limit the tokens returned by the runtime errors tool/resource.
* Add RootsFallbackSupport mixin.
* Fix error handling around stream listeners.
* Add a 'pub-dev-search' mcp tool.
* Drop pubspec-parse, use yaml instead.
* Handle failing to listen to vm service streams during startup.
* Add tool for enabling/disabling the widget selector.
* Add a tool to get the active cursor location.
* Add hover tool support.
* Add a test command and project detection.
* Add signature_help tool.
* Add runtime errors resource and tool to clear errors.
* Require roots for all CLI tools.
* Require roots to be set for analyzer tools.
* Add debug logs for when DTD sees Editor.getDebugSessions get registered.
* Add tool annotations to tools.
* Implement a tool to resolve workspace symbols based on a query.
* Add a dart pub tool.
* Update analyze tool to use LSP, simplify tool.
* Add tool for getting the selected widget.
* Handle missing roots capability better.
* Add `get_widget_tree` tool.
* Add a tool for getting runtime errors.
* Add Dart CLI tool support.
* Add a hot reload tool.
* Add basic analysis support.
* Add the beginnings of a Dart tooling MCP server.
* Instruct clients to prefer MCP tools over running tools in the shell.
* Reduce output size of `run_tests` tool to save on input tokens.
* Add `--log-file` argument to log all protocol traffic to a file.
* Improve error text for failed DTD connections as well as the tool description.
* Add support for injecting an `Analytics` instance to track usage.
* Listen to the new DTD `ConnectedApp` service instead of the `Editor.DebugSessions`
- Add documentation/homepage/repository links to pub results.
- Handle relative paths under roots without trailing slashes.
- Fix executable paths for dart/flutter on windows.
- Pass the provided root instead of the resolved root for project type detection.
- Be more flexible about roots by comparing canonicalized paths.
- Create the working dir if it doesn't exist.
- Add the --platform and --empty arguments to the flutter create tool.
- Invoke dart/flutter in a more robust way.
- Remove qualifiedNames from the pub dev api search.
- Flutter/Dart create tool.
- Limit the tokens returned by the runtime errors tool/resource.
- Add RootsFallbackSupport mixin.
- Fix error handling around stream listeners.
- Add a 'pub-dev-search' mcp tool.
- Drop pubspec-parse, use yaml instead.
- Handle failing to listen to vm service streams during startup.
- Add tool for enabling/disabling the widget selector.
- Add a tool to get the active cursor location.
- Add hover tool support.
- Add a test command and project detection.
- Add signature_help tool.
- Add runtime errors resource and tool to clear errors.
- Require roots for all CLI tools.
- Require roots to be set for analyzer tools.
- Add debug logs for when DTD sees Editor.getDebugSessions get registered.
- Add tool annotations to tools.
- Implement a tool to resolve workspace symbols based on a query.
- Add a dart pub tool.
- Update analyze tool to use LSP, simplify tool.
- Add tool for getting the selected widget.
- Handle missing roots capability better.
- Add `get_widget_tree` tool.
- Add a tool for getting runtime errors.
- Add Dart CLI tool support.
- Add a hot reload tool.
- Add basic analysis support.
- Add the beginnings of a Dart tooling MCP server.
- Instruct clients to prefer MCP tools over running tools in the shell.
- Reduce output size of `run_tests` tool to save on input tokens.
- Add `--log-file` argument to log all protocol traffic to a file.
- Improve error text for failed DTD connections as well as the tool description.
- Add support for injecting an `Analytics` instance to track usage.
- Listen to the new DTD `ConnectedApp` service instead of the `Editor.DebugSessions`
service, when available.
* Screenshot tool disabled until
- Screenshot tool disabled until
https://github.com/flutter/flutter/issues/170357 is resolved.
* Add `arg_parser.dart` public library with minimal deps to be used by the dart tool.
- Add `arg_parser.dart` public library with minimal deps to be used by the dart tool.
32 changes: 23 additions & 9 deletions pkgs/dart_mcp_server/lib/src/mixins/flutter_launcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ base mixin FlutterLauncherSupport
sdk.flutterExecutablePath,
'run',
'--print-dtd',
'--machine',
'--device-id',
device,
if (target != null) '--target',
Expand All @@ -116,16 +117,29 @@ base mixin FlutterLauncherSupport

late StreamSubscription stdoutSubscription;
late StreamSubscription stderrSubscription;
final dtdUriRegex = RegExp(
r'The Dart Tooling Daemon is available at: (ws://.+:\d+/\S+=)',
);

void checkForDtdUri(String line) {
final match = dtdUriRegex.firstMatch(line);
if (match != null && !completer.isCompleted) {
final dtdUri = Uri.parse(match.group(1)!);
log(LoggingLevel.debug, 'Found DTD URI: $dtdUri');
completer.complete((dtdUri: dtdUri, pid: process!.pid));
line = line.trim();
// Check for --machine output first.
if (line.startsWith('[') && line.endsWith(']')) {
// Looking for:
// [{"event":"app.dtd","params":{"appId":"cd6c66eb-35e9-4ac1-96df-727540138346","uri":"ws://127.0.0.1:59548/3OpAaPw9i34="}}]
try {
final json =
jsonDecode(line.substring(1, line.length - 1))
as Map<String, Object?>;
if (json['event'] == 'app.dtd' && json['params'] != null) {
final params = json['params'] as Map<String, Object?>;
if (params['uri'] != null) {
final dtdUri = Uri.parse(params['uri'] as String);
log(LoggingLevel.debug, 'Found machine DTD URI: $dtdUri');
completer.complete((dtdUri: dtdUri, pid: process!.pid));
}
}
} on FormatException {
// Ignore failures to parse the JSON or the URI.
log(LoggingLevel.debug, 'Failed to parse $line for the DTD URI.');
}
}
}

Expand Down Expand Up @@ -213,7 +227,7 @@ base mixin FlutterLauncherSupport
} catch (e, s) {
log(LoggingLevel.error, 'Error launching Flutter application: $e\n$s');
if (process != null) {
process.kill();
processManager.killPid(process.pid);
// The exitCode handler will perform the rest of the cleanup.
}
return CallToolResult(
Expand Down
1 change: 1 addition & 0 deletions pkgs/dart_mcp_server/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ dependencies:
dev_dependencies:
analyzer: ^7.5.2
dart_flutter_team_lints: ^3.2.1
fake_async: ^1.3.3
pub_semver: ^2.2.0
test: ^1.25.15
test_descriptor: ^2.0.2
Expand Down
Loading