Skip to content

improve tool description for the dtd connection tool and improve error messages #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 18, 2025
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
1 change: 1 addition & 0 deletions pkgs/dart_mcp_server/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@
* 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.
20 changes: 16 additions & 4 deletions pkgs/dart_mcp_server/lib/src/mixins/dtd.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:json_rpc_2/json_rpc_2.dart';
import 'package:meta/meta.dart';
import 'package:vm_service/vm_service.dart';
import 'package:vm_service/vm_service_io.dart';
import 'package:web_socket/web_socket.dart';

import '../utils/constants.dart';

Expand Down Expand Up @@ -182,10 +183,19 @@ base mixin DartToolingDaemonSupport
return CallToolResult(
content: [TextContent(text: 'Connection succeeded')],
);
} on WebSocketException catch (_) {
return CallToolResult(
isError: true,
content: [
Content.text(
text: 'Connection failed, make sure your DTD Uri is up to date.',
),
],
);
} catch (e) {
return CallToolResult(
isError: true,
content: [TextContent(text: 'Connection failed: $e')],
content: [Content.text(text: 'Connection failed: $e')],
);
}
}
Expand Down Expand Up @@ -602,9 +612,11 @@ base mixin DartToolingDaemonSupport
static final connectTool = Tool(
name: 'connect_dart_tooling_daemon',
description:
'Connects to the Dart Tooling Daemon. You should ask the user for the '
'dart tooling daemon URI, and suggest the "Copy DTD Uri to clipboard" '
'command. Do not just make up a random URI to pass.',
'Connects to the Dart Tooling Daemon. You should get the uri either '
'from available tools or the user, do not just make up a random URI to '
'pass. When asking the user for the uri, you should suggest the "Copy '
'DTD Uri to clipboard" action. Do . When reconnecting after losing a '
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think "Do ." was intended to be left here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whoops!

'connection, always request a new uri first.',
annotations: ToolAnnotations(title: 'Connect to DTD', readOnlyHint: true),
inputSchema: Schema.object(
properties: {ParameterNames.uri: Schema.string()},
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 @@ -35,6 +35,7 @@ dependencies:
stream_channel: ^2.1.4
vm_service: ^15.0.0
watcher: ^1.1.1
web_socket: ^1.0.1
yaml: ^3.1.3

dev_dependencies:
Expand Down