-
Notifications
You must be signed in to change notification settings - Fork 28
add a CI check that the readme file is up-to-date #192
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
Changes from 4 commits
74a368d
f8fb740
8b742d7
7eb3c05
ee3fbe2
4f1d7de
ceed61c
d392b26
e629039
80cfa31
b049485
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'dart:io'; | ||
|
||
import 'package:dart_mcp/client.dart'; | ||
|
||
void main(List<String> args) async { | ||
print('Getting registered tools...'); | ||
|
||
final tools = await _retrieveRegisteredTools(); | ||
|
||
final buf = StringBuffer(''' | ||
| Name | Title | Description | | ||
| --- | --- | --- | | ||
'''); | ||
for (final tool in tools) { | ||
buf.writeln('| `${tool.name}` | ${tool.title} | ${tool.description} |'); | ||
} | ||
|
||
final readmeFile = File('README.md'); | ||
final updated = _insertBetween( | ||
readmeFile.readAsStringSync(), | ||
buf.toString(), | ||
'<!-- generated -->', | ||
); | ||
readmeFile.writeAsStringSync(updated); | ||
|
||
print('Wrote update tool list to ${readmeFile.path}.'); | ||
} | ||
|
||
String _insertBetween(String original, String insertion, String marker) { | ||
final startIndex = original.indexOf(marker) + marker.length; | ||
final endIndex = original.lastIndexOf(marker); | ||
|
||
return '${original.substring(0, startIndex)}\n\n' | ||
'$insertion\n${original.substring(endIndex)}'; | ||
} | ||
|
||
Future<List<Tool>> _retrieveRegisteredTools() async { | ||
final client = MCPClient( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fwiw, the tools registered can vary based on the client features that are supported. Probably, this client should claim to support all features so that all the tools show up. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked at creating a subclass of an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What likely happened there is we swapped out some tools for their preferred alternatives (resources), due to the client indicating it has resource support. We can land this as is though and I can eventually take a look at improving it. |
||
Implementation(name: 'list tools client', version: '1.0.0'), | ||
); | ||
final server = await client.connectStdioServer('dart', [ | ||
'run', | ||
'bin/main.dart', | ||
]); | ||
|
||
await server.initialize( | ||
InitializeRequest( | ||
protocolVersion: ProtocolVersion.latestSupported, | ||
capabilities: client.capabilities, | ||
clientInfo: client.implementation, | ||
), | ||
); | ||
server.notifyInitialized(InitializedNotification()); | ||
|
||
final toolsResult = await server.listTools(ListToolsRequest()); | ||
await client.shutdown(); | ||
return toolsResult.tools; | ||
} | ||
|
||
extension on Tool { | ||
String get title => toolAnnotations?.title ?? ''; | ||
} |
Uh oh!
There was an error while loading. Please reload this page.