Skip to content
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
7 changes: 7 additions & 0 deletions pkgs/dart_mcp/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
## 0.3.3-wip

- Fix `PingRequest` handling when it is sent from a non-Dart client.
- Deprecate `ElicitationAction.reject` and replace it with
`ElicitationAction.decline`.
- In the initial elicitations schema this was incorrectly listed as `reject`.
- This package still allows `reject` and treats it as an alias for`decline`.
- The old `reject` enum value was replaced with a static constant equal
exactly to `decline`, so switches are not affected.


## 0.3.2

Expand Down
4 changes: 2 additions & 2 deletions pkgs/dart_mcp/example/elicitations_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ final class TestMCPClientWithElicitationSupport extends MCPClient
print('''
Elicitation received from server: ${request.message}

Do you want to accept (a), reject (r), or cancel (c) the elicitation?
Do you want to accept (a), decline (d), or cancel (c) the elicitation?
''');
final answer = stdin.readLineSync();
final action = switch (answer) {
'a' => ElicitationAction.accept,
'r' => ElicitationAction.reject,
'd' => ElicitationAction.decline,
'c' => ElicitationAction.cancel,
_ => throw ArgumentError('Invalid answer: $answer'),
};
Expand Down
4 changes: 2 additions & 2 deletions pkgs/dart_mcp/example/elicitations_server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ base class MCPServerWithElicitation extends MCPServer
'Hello $name! I see that you are $age years '
'old and identify as $gender',
);
case ElicitationAction.reject:
log(LoggingLevel.warning, 'Request for name was rejected');
case ElicitationAction.decline:
log(LoggingLevel.warning, 'Request for name was declined');
case ElicitationAction.cancel:
log(LoggingLevel.warning, 'Request for name was cancelled');
}
Expand Down
16 changes: 12 additions & 4 deletions pkgs/dart_mcp/lib/src/api/elicitation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,19 @@ extension type ElicitResult.fromMap(Map<String, Object?> _value)
///
/// - [ElicitationAction.accept]: The user accepted the request and provided
/// the requested information.
/// - [ElicitationAction.reject]: The user explicitly declined the action.
/// - [ElicitationAction.decline]: The user explicitly declined the action.
/// - [ElicitationAction.cancel]: The user dismissed without making an
/// explicit choice.
ElicitationAction get action {
final action = _value['action'] as String?;
var action = _value['action'] as String?;
if (action == null) {
throw ArgumentError('Missing required action field in $ElicitResult');
}
// There was a bug in the initial schema, where the `decline` action was
// named `reject` instead. Handle using that as an alias for `decline` in
// case some clients use the old name.
if (action == 'reject') action = 'decline';

return ElicitationAction.values.byName(action);
}

Expand All @@ -131,8 +136,11 @@ enum ElicitationAction {
accept,

/// The user explicitly declined the action.
reject,
decline,

/// The user dismissed without making an explicit choice.
cancel,
cancel;

@Deprecated('Use `ElicitationAction.decline` instead.')
static const reject = decline;
}