notifyProgress method
Report progress on an in-flight server-initiated request (spec
notifications/progress). progressToken is the token the server
sent in the original request's _meta.progressToken.
Only for a server request still being handled, and only with a value greater than the last one sent for that token.
Implementation
void notifyProgress(
dynamic progressToken,
double progress, {
double? total,
String? message,
}) {
if (!_initialized) {
throw McpError('Client is not initialized');
}
if (!_incomingProgress.containsKey(progressToken)) {
throw ArgumentError.value(progressToken, 'progressToken', 'no server request in flight with that token');
}
final last = _incomingProgress[progressToken];
if (last != null && progress <= last) {
throw ArgumentError.value(progress, 'progress', 'must increase (last was $last)');
}
_incomingProgress[progressToken] = progress;
_sendNotification('notifications/progress', {
'progressToken': progressToken,
'progress': progress,
if (total != null) 'total': total,
if (message != null) 'message': message,
});
}