complete method

Future<CompleteResult> complete(
  1. Map<String, dynamic> ref,
  2. Map<String, dynamic> argument, {
  3. Map<String, dynamic>? context,
  4. Map<String, dynamic>? meta,
  5. RequestOptions? options,
})

Requests completion candidates for one argument of a prompt or resource reference (completion/complete).

ref is the reference being completed, e.g. {'type': 'ref/prompt', 'name': 'greet'} or {'type': 'ref/resource', 'uri': 'test://item/{id}'}. argument is {'name': ..., 'value': ...} — the partial value typed so far. context optionally carries already-resolved arguments.

Implementation

Future<CompleteResult> complete(
  Map<String, dynamic> ref,
  Map<String, dynamic> argument, {
  Map<String, dynamic>? context,
  Map<String, dynamic>? meta,
  RequestOptions? options,
}) async {
  if (!_initialized) {
    throw McpError('Client is not initialized');
  }
  final result = await _sendRequest(
      'completion/complete',
      _withMeta({
        'ref': ref,
        'argument': argument,
        if (context != null) 'context': context,
      }, meta), options);
  return CompleteResult.fromJson(result);
}