File tree Expand file tree Collapse file tree 5 files changed +32
-10
lines changed Expand file tree Collapse file tree 5 files changed +32
-10
lines changed Original file line number Diff line number Diff line change
1
+ ## 0.3.3-wip
2
+
3
+ - Fix ` PingRequest ` handling when it is sent from a non-Dart client.
4
+
1
5
## 0.3.2
2
6
3
7
- Deprecate the ` EnumSchema ` type in favor of the ` StringSchema ` with an
Original file line number Diff line number Diff line change @@ -225,9 +225,12 @@ extension type RequestId( /*String|int*/ Parameter _) {}
225
225
///
226
226
/// The receiver must promptly respond, or else may be disconnected.
227
227
///
228
- /// The request itself has no parameters and should always be just `null` .
229
- extension type PingRequest ._(Null _) {
228
+ /// The request itself has no parameters.
229
+ extension type PingRequest ._(Map < String , Object ?> _) implements Request {
230
230
static const methodName = 'ping' ;
231
+
232
+ factory PingRequest ({MetaWithProgressToken ? meta}) =>
233
+ PingRequest ._({if (meta != null ) '_meta' : meta});
231
234
}
232
235
233
236
/// An out-of-band notification used to inform the receiver of a progress
Original file line number Diff line number Diff line change @@ -131,8 +131,6 @@ base class MCPBase {
131
131
132
132
/// The peer may ping us at any time, and we should respond with an empty
133
133
/// response.
134
- ///
135
- /// Note that [PingRequest] is always actually just `null` .
136
134
EmptyResult _handlePing ([PingRequest ? _]) => EmptyResult ();
137
135
138
136
/// Handles [ProgressNotification] s and forwards them to the streams returned
@@ -172,11 +170,13 @@ base class MCPBase {
172
170
///
173
171
/// If the timeout is reached, future values or errors from the ping request
174
172
/// are ignored.
175
- Future <bool > ping ({Duration timeout = const Duration (seconds: 1 )}) =>
176
- sendRequest <EmptyResult >(
177
- PingRequest .methodName,
178
- null ,
179
- ).then ((_) => true ).timeout (timeout, onTimeout: () => false );
173
+ Future <bool > ping ({
174
+ Duration timeout = const Duration (seconds: 1 ),
175
+ PingRequest ? request,
176
+ }) => sendRequest <EmptyResult >(
177
+ PingRequest .methodName,
178
+ request,
179
+ ).then ((_) => true ).timeout (timeout, onTimeout: () => false );
180
180
181
181
/// If [protocolLogSink] is non-null, emits messages to it for all messages
182
182
/// sent over [channel] .
Original file line number Diff line number Diff line change 1
1
name : dart_mcp
2
- version : 0.3.2
2
+ version : 0.3.3-wip
3
3
description : A package for making MCP servers and clients.
4
4
repository : https://github.com/dart-lang/ai/tree/main/pkgs/dart_mcp
5
5
issue_tracker : https://github.com/dart-lang/ai/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Adart_mcp
Original file line number Diff line number Diff line change @@ -127,6 +127,21 @@ void main() {
127
127
);
128
128
});
129
129
130
+ // Regression test for https://github.com/dart-lang/ai/issues/238.
131
+ test ('client and server can handle ping with non-null parameters' , () async {
132
+ final environment = TestEnvironment (TestMCPClient (), TestMCPServer .new );
133
+ await environment.initializeServer ();
134
+
135
+ await expectLater (
136
+ environment.serverConnection.ping (request: PingRequest ()),
137
+ completes,
138
+ );
139
+ await expectLater (
140
+ environment.server.ping (request: PingRequest ()),
141
+ completes,
142
+ );
143
+ });
144
+
130
145
test (
131
146
'server can handle initialized notification with null parameters' ,
132
147
() async {
You can’t perform that action at this time.
0 commit comments