-
Notifications
You must be signed in to change notification settings - Fork 23
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
Open
devoncarew
wants to merge
6
commits into
main
Choose a base branch
from
readme_ci
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
74a368d
add a CI check that the readme file is up-to-date
devoncarew f8fb740
re-generate the readme
devoncarew 8b742d7
Merge branch 'main' into readme_ci
devoncarew 7eb3c05
rewrite from review feedback
devoncarew ee3fbe2
merge to main
devoncarew 4f1d7de
tweak markdown table
devoncarew File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// 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(''' | ||
| Tool Name | Title | Description | | ||
| --- | --- | --- | | ||
'''); | ||
for (final tool in tools) { | ||
buf.writeln( | ||
'| `${tool.name}` | ${tool.displayName} | ${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. |
||
Implementation(name: 'list tools client', version: '1.0.0'), | ||
); | ||
final process = await Process.start('dart', ['run', 'bin/main.dart']); | ||
final server = client.connectStdioServer( | ||
process.stdin, | ||
process.stdout, | ||
onDone: process.kill, | ||
); | ||
|
||
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 displayName => toolAnnotations?.title ?? ''; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could just merge this into the job above to avoid the extra setup work 🤷♂️ . This repo isn't large enough to really need multiple jobs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept this separate since this above job was doing more than we need here (using the flutter sdk instead of the dart sdk, ...).