getTask method

Future<GetTaskResult> getTask(
  1. String taskId, {
  2. Map<String, dynamic>? meta,
  3. RequestOptions? options,
})

Poll a task's current state (tasks/get): the task plus, in the extension, inputRequests / result / error for its state.

Implementation

Future<GetTaskResult> getTask(String taskId, {Map<String, dynamic>? meta, RequestOptions? options}) async {
  if (!isConnected) throw McpError('Client is not connected to a transport');
  final response =
      await _sendRequest('tasks/get', _withMeta({'taskId': taskId}, meta), options);
  if (response == null) throw McpError('tasks/get returned no result');
  return GetTaskResult.fromJson(Map<String, dynamic>.from(response as Map));
}