-
Notifications
You must be signed in to change notification settings - Fork 29
Description
When using the dart_mcp, several tools that interact with a running application fail with the following error message:
A Dart SDK of version 3.9.0-163.0.dev or greater is required to connect to Dart and Flutter applications.
This error is misleading, as the Dart SDK version being used is higher than the required version.
Affected Tools
The following tools have been confirmed to be affected by this issue:
- get_widget_tree
- get_runtime_errors
- hot_reload
- get_selected_widget
- set_widget_selection_mode
Root Cause Analysis
The root cause of this issue appears to be a bug in the _listenForServices function in pkgs/dart_mcp_server/lib/src/mixins/dtd.dart. The code that checks for the ConnectedApp service is wrapped in a try-catch block that silently ignores any errors:
try {
final registeredServices = await dtd.getRegisteredServices();
if (registeredServices.dtdServices.contains(
'${ConnectedAppServiceConstants.serviceName}.${ConnectedAppServiceConstants.getVmServices}',
)) {
_connectedAppServiceIsSupported = true;
}
} catch (_) {}
If dtd.getRegisteredServices() throws an exception, it is caught silently, and the _connectedAppServiceIsSupported flag is not set to true. This leads to the misleading error message about the SDK version for all tools that rely on this flag.
Steps to Reproduce
- Connect to the Dart Tooling Daemon using the connect_dart_tooling_daemon tool.
- Call any of the affected tools listed above.
Expected Behavior
The tools should execute successfully.
Actual Behavior
The tools fail with a misleading error message about the SDK version.
Environment
- Flutter Version: Flutter 3.35.0-0.1.pre
- Dart Version: Dart 3.9.0 (build 3.9.0-333.2.beta)
- Operating System: macOS 15.5 24F74 darwin-arm64