-
Notifications
You must be signed in to change notification settings - Fork 21
Add enum support to Schema
#190
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
Conversation
PR HealthChangelog Entry ✔️
Changes to files need to be accounted for in their respective changelogs. |
pkgs/dart_mcp/lib/src/api/tools.dart
Outdated
String? get description => _value['description'] as String?; | ||
|
||
/// The allowed enum values. | ||
Set<String> get values => (_value['enum'] as Set).cast<String>(); |
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.
Should we handle null values better here similar to the previous PR?
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.
Yes, we should.
pkgs/dart_mcp/lib/src/api/tools.dart
Outdated
String? get description => _value['description'] as String?; | ||
|
||
/// The allowed enum values. | ||
Set<String> get values => (_value['enum'] as Set).cast<String>(); |
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.
This is typically going to be a List
, not a Set
. We could call toSet
, but I would probably just make it have an Iterable
type so that it can be either? We should also validate that the JSON encoder can handle any kind of Iterable.
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.
Yeah, I went back and forth on that too. Okay, I'll just make it an Iterable
.
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 left out the .toSet, but I did add an assert to check for duplicate entries, which is why I wanted to use .toSet in the first place.
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.
We should also add a custom "constructor" (actually static method) to the Schema class (see the other ones there)
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.
See latest comment, one last thing to do actually before landing
Revisions updated by `dart tools/rev_sdk_deps.dart`. ai (https://github.com/dart-lang/ai/compare/706d224..d0b89cf): d0b89cf 2025-06-25 Greg Spencer Add enum support to `Schema` (dart-lang/ai#190) f219861 2025-06-26 Brett Morgan Update `simple_server.dart` (dart-lang/ai#187) 8e3365f 2025-06-24 Greg Spencer Add error checks for accessing Request members (dart-lang/ai#184) protobuf (https://github.com/dart-lang/protobuf/compare/0bfff0c..bce362d): bce362d 2025-06-24 Devon Carew prep to publish 22.4.0 (google/protobuf.dart#1023) 269e004 2025-06-24 Devon Carew improve the readability of generated gRPC client files (google/protobuf.dart#1021) 48ba649 2025-06-24 Devon Carew update the header for generated files (google/protobuf.dart#1022) webdev (https://github.com/dart-lang/webdev/compare/6dc3dde..7f376d2): 7f376d24 2025-06-25 Derek Xu Set package versions to WIP versions (dart-lang/webdev#2637) Change-Id: Ib720f5127f3fddeb82b62cf13f24c3ddb4038e33 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437260 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Auto-Submit: Devon Carew <devoncarew@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Description
In preparation for adding Elicitation support, this add
enum
support to the Schema class.Elicitations can request enum responses as part of their
requestedSchema
.Tests