taskResult method
2025-11-25 tasks/result: wait for the task to end and return what the
underlying request returned (its JSON-RPC error is thrown as McpError).
Implementation
Future<Map<String, dynamic>> taskResult(String taskId, {RequestOptions? options}) async {
final response = await _sendRequest('tasks/result', {'taskId': taskId},
options ?? const RequestOptions(timeout: Duration(hours: 1)));
final result = Map<String, dynamic>.from(response as Map);
final meta = result['_meta'];
if (meta is Map) {
final rest = Map<String, dynamic>.from(meta)..remove('io.modelcontextprotocol/related-task');
if (rest.isEmpty) {
result.remove('_meta');
} else {
result['_meta'] = rest;
}
}
return result;
}