Skip to content

Multiple DTD tools fail with misleading SDK version error #256

@goodbbai

Description

@goodbbai

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

  1. Connect to the Dart Tooling Daemon using the connect_dart_tooling_daemon tool.
  2. 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

Metadata

Metadata

Assignees

Labels

P1A high priority bug; for example, a single project is unusable or has many test failurespackage:dart_mcp_servertype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions