callToolWithTracking method

Future<ToolCallTracking> callToolWithTracking(
  1. String name,
  2. Map<String, dynamic> arguments, {
  3. bool trackProgress = true,
})

Call a tool and get the operation ID for tracking progress

name - The name of the tool to call arguments - The arguments to pass to the tool trackProgress - Whether to track progress for this tool call

Returns a Future that resolves to a tuple of (operationId, result)

Implementation

Future<ToolCallTracking> callToolWithTracking(
  String name,
  Map<String, dynamic> arguments, {
  bool trackProgress = true,
}) async {
  if (!_initialized) {
    throw McpError('Client is not initialized');
  }

  if (_serverCapabilities?.tools != true) {
    throw McpError('Server does not support tools');
  }

  final params = {
    'name': name,
    'arguments': Map<String, dynamic>.from(arguments),
    'trackProgress': trackProgress,
  };

  final response = await _sendRequest('tools/call', params);
  final operationId = response['operationId'] as String?;
  final result = CallToolResult.fromJson(response);

  return ToolCallTracking(operationId: operationId, result: result);
}