Skip to content

Commit b77cda5

Browse files
authored
add a CI check that the readme file is up-to-date (#192)
1 parent 9c62524 commit b77cda5

File tree

3 files changed

+100
-21
lines changed

3 files changed

+100
-21
lines changed

.github/workflows/dart_mcp_server.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,12 @@ jobs:
5858
run: flutter pub get
5959

6060
- run: dart pub get
61-
6261
- run: dart analyze --fatal-infos
63-
6462
- run: dart format --output=none --set-exit-if-changed .
6563
if: ${{ matrix.flutterSdk == 'master' }}
6664

65+
# If this fails, you need to run 'dart tool/update_readme.dart'.
66+
- run: dart tool/update_readme.dart
67+
- run: git diff --exit-code README.md
68+
6769
- run: dart test

pkgs/dart_mcp_server/README.md

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -129,23 +129,30 @@ For more information, see the official VS Code documentation for
129129

130130
## Tools
131131

132-
| Tool Name | Feature Group | Description |
132+
<!-- run 'dart tool/update_readme.dart' to update -->
133+
134+
<!-- generated -->
135+
136+
| Tool Name | Title | Description |
133137
| --- | --- | --- |
134-
| `analyze_files` | `static analysis` | Analyzes the entire project for errors. |
135-
| `signature_help` | `static_analysis` | Gets signature information for usage at a given cursor position. |
136-
| `hover` | `static_analysis` | Gets the hover information for a given cursor position. |
137-
| `resolve_workspace_symbol` | `static analysis` | Look up a symbol or symbols in all workspaces by name. |
138-
| `dart_fix` | `static tool` | Runs `dart fix --apply` for the given project roots. |
139-
| `dart_format` | `static tool` | Runs `dart format .` for the given project roots. |
140-
| `pub` | `static tool` | Runs a `dart pub` command for the given project roots. |
141-
| `pub_dev_search` | `package search` | Searches pub.dev for packages relevant to a given search query. |
142-
| `get_runtime_errors` | `runtime analysis` | Retrieves the list of runtime errors that have occurred in the active Dart or Flutter application. |
143-
| `get_widget_tree` | `runtime analysis` | Retrieves the widget tree from the active Flutter application. |
144-
| `get_selected_widget` | `runtime analysis` | Retrieves the selected widget from the active Flutter application. |
145-
| `hot_reload` | `runtime tool` | Performs a hot reload of the active Flutter application. |
146-
| `connect_dart_tooling_daemon`* | `configuration` | Connects to the locally running Dart Tooling Daemon. |
147-
| `get_active_location` | `editor` | Gets the active cursor position in the connected editor (if available). |
148-
| `run_tests` | `static tool` | Runs tests for the given project roots. |
149-
| `create_project` | `static tool` | Creates a new Dart or Flutter project. |
150-
151-
> *Experimental: may be removed.
138+
| `connect_dart_tooling_daemon` | Connect to DTD | 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. When reconnecting after losing a connection, always request a new uri first. |
139+
| `get_runtime_errors` | Get runtime errors | Retrieves the most recent runtime errors that have occurred in the active Dart or Flutter application. Requires "connect_dart_tooling_daemon" to be successfully called first. |
140+
| `hot_reload` | Hot reload | Performs a hot reload of the active Flutter application. This is to apply the latest code changes to the running application. Requires "connect_dart_tooling_daemon" to be successfully called first. |
141+
| `get_widget_tree` | Get widget tree | Retrieves the widget tree from the active Flutter application. Requires "connect_dart_tooling_daemon" to be successfully called first. |
142+
| `get_selected_widget` | Get selected widget | Retrieves the selected widget from the active Flutter application. Requires "connect_dart_tooling_daemon" to be successfully called first. |
143+
| `set_widget_selection_mode` | Set Widget Selection Mode | Enables or disables widget selection mode in the active Flutter application. Requires "connect_dart_tooling_daemon" to be successfully called first. |
144+
| `get_active_location` | Get Active Editor Location | Retrieves the current active location (e.g., cursor position) in the connected editor. Requires "connect_dart_tooling_daemon" to be successfully called first. |
145+
| `pub_dev_search` | pub.dev search | Searches pub.dev for packages relevant to a given search query. The response will describe each result with its download count, package description, topics, license, and publisher. |
146+
| `remove_roots` | Remove roots | Removes one or more project roots previously added via the add_roots tool. |
147+
| `add_roots` | Add roots | Adds one or more project roots. Tools are only allowed to run under these roots, so you must call this function before passing any roots to any other tools. |
148+
| `dart_fix` | Dart fix | Runs `dart fix --apply` for the given project roots. |
149+
| `dart_format` | Dart format | Runs `dart format .` for the given project roots. |
150+
| `run_tests` | Run tests | Run Dart or Flutter tests with an agent centric UX. ALWAYS use instead of `dart test` or `flutter test` shell commands. |
151+
| `create_project` | Create project | Creates a new Dart or Flutter project. |
152+
| `pub` | pub | Runs a pub command for the given project roots, like `dart pub get` or `flutter pub add`. |
153+
| `analyze_files` | Analyze projects | Analyzes the entire project for errors. |
154+
| `resolve_workspace_symbol` | Project search | Look up a symbol or symbols in all workspaces by name. Can be used to validate that a symbol exists or discover small spelling mistakes, since the search is fuzzy. |
155+
| `signature_help` | Signature help | Get signature help for an API being used at a given cursor position in a file. |
156+
| `hover` | Hover information | Get hover information at a given cursor position in a file. This can include documentation, type information, etc for the text at that position. |
157+
158+
<!-- generated -->
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'dart:io';
6+
7+
import 'package:dart_mcp/client.dart';
8+
9+
void main(List<String> args) async {
10+
print('Getting registered tools...');
11+
12+
final tools = await _retrieveRegisteredTools();
13+
14+
final buf = StringBuffer('''
15+
| Tool Name | Title | Description |
16+
| --- | --- | --- |
17+
''');
18+
for (final tool in tools) {
19+
buf.writeln(
20+
'| `${tool.name}` | ${tool.displayName} | ${tool.description} |',
21+
);
22+
}
23+
24+
final readmeFile = File('README.md');
25+
final updated = _insertBetween(
26+
readmeFile.readAsStringSync(),
27+
buf.toString(),
28+
'<!-- generated -->',
29+
);
30+
readmeFile.writeAsStringSync(updated);
31+
32+
print('Wrote update tool list to ${readmeFile.path}.');
33+
}
34+
35+
String _insertBetween(String original, String insertion, String marker) {
36+
final startIndex = original.indexOf(marker) + marker.length;
37+
final endIndex = original.lastIndexOf(marker);
38+
39+
return '${original.substring(0, startIndex)}\n\n'
40+
'$insertion\n${original.substring(endIndex)}';
41+
}
42+
43+
Future<List<Tool>> _retrieveRegisteredTools() async {
44+
final client = MCPClient(
45+
Implementation(name: 'list tools client', version: '1.0.0'),
46+
);
47+
final process = await Process.start('dart', ['run', 'bin/main.dart']);
48+
final server = client.connectStdioServer(
49+
process.stdin,
50+
process.stdout,
51+
onDone: process.kill,
52+
);
53+
54+
await server.initialize(
55+
InitializeRequest(
56+
protocolVersion: ProtocolVersion.latestSupported,
57+
capabilities: client.capabilities,
58+
clientInfo: client.implementation,
59+
),
60+
);
61+
server.notifyInitialized(InitializedNotification());
62+
63+
final toolsResult = await server.listTools(ListToolsRequest());
64+
await client.shutdown();
65+
return toolsResult.tools;
66+
}
67+
68+
extension on Tool {
69+
String get displayName => toolAnnotations?.title ?? '';
70+
}

0 commit comments

Comments
 (0)