Skip to content

Commit 909c319

Browse files
committed
Review changes
1 parent 4f34cf6 commit 909c319

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

pkgs/dart_mcp/lib/src/api/initialization.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,19 @@ extension type InitializeRequest._fromMap(Map<String, Object?> _value)
3131
ProtocolVersion.tryParse(_value['protocolVersion'] as String);
3232

3333
ClientCapabilities get capabilities {
34-
if (_value['capabilities'] == null) {
34+
final capabilities = _value['capabilities'] as ClientCapabilities?;
35+
if (capabilities == null) {
3536
throw ArgumentError('Missing capabilities field in $InitializeRequest.');
3637
}
37-
return _value['capabilities'] as ClientCapabilities;
38+
return capabilities;
3839
}
3940

4041
Implementation get clientInfo {
4142
if (_value['clientInfo'] == null) {
4243
throw ArgumentError('Missing clientInfo field in $InitializeRequest.');
44+
} else {
45+
return _value['clientInfo'] as Implementation;
4346
}
44-
return _value['clientInfo'] as Implementation;
4547
}
4648
}
4749

pkgs/dart_mcp/lib/src/api/prompts.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ extension type GetPromptRequest.fromMap(Map<String, Object?> _value)
5252
String get name {
5353
if (_value['name'] == null) {
5454
throw ArgumentError('Missing name field in $GetPromptRequest.');
55+
} else {
56+
return _value['name'] as String;
5557
}
56-
return _value['name'] as String;
5758
}
5859

5960
/// Arguments to use for templating the prompt.

pkgs/dart_mcp/lib/src/api/resources.dart

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,11 @@ extension type ReadResourceRequest.fromMap(Map<String, Object?> _value)
8181
/// The URI of the resource to read. The URI can use any protocol; it is
8282
/// up to the server how to interpret it.
8383
String get uri {
84-
if (_value['uri'] == null) {
84+
final uri = _value['uri'] as String?;
85+
if (uri == null) {
8586
throw ArgumentError('Missing uri field in $ReadResourceRequest.');
8687
}
87-
return _value['uri'] as String;
88+
return uri;
8889
}
8990
}
9091

@@ -134,10 +135,11 @@ extension type SubscribeRequest.fromMap(Map<String, Object?> _value)
134135
/// The URI of the resource to subscribe to. The URI can use any protocol;
135136
/// it is up to the server how to interpret it.
136137
String get uri {
137-
if (_value['uri'] == null) {
138+
final uri = _value['uri'] as String?;
139+
if (uri == null) {
138140
throw ArgumentError('Missing uri field in $SubscribeRequest.');
139141
}
140-
return _value['uri'] as String;
142+
return uri;
141143
}
142144
}
143145

@@ -157,10 +159,11 @@ extension type UnsubscribeRequest.fromMap(Map<String, Object?> _value)
157159

158160
/// The URI of the resource to unsubscribe from.
159161
String get uri {
160-
if (_value['uri'] == null) {
162+
final uri = _value['uri'] as String?;
163+
if (uri == null) {
161164
throw ArgumentError('Missing uri field in $UnsubscribeRequest.');
162165
}
163-
return _value['uri'] as String;
166+
return uri;
164167
}
165168
}
166169

0 commit comments

Comments
 (0)