CompletionHandler typedef

CompletionHandler = Future<Map<String, dynamic>> Function(Map<String, dynamic> ref, Map<String, dynamic> argument, Map<String, dynamic>? context)

Type definition for completion handler functions (spec completion/complete).

ref identifies which prompt or resource template the completion is for. Spec shapes:

  • { "type": "ref/prompt", "name": "..." }
  • { "type": "ref/resource", "uri": "..." }

argument is { name, value } — the partial value being completed. context holds previously-resolved arguments (spec 2025-06-18).

Returns { values, total?, hasMore? }. values MUST have ≤ 100 entries.

Implementation

typedef CompletionHandler = Future<Map<String, dynamic>> Function(
  Map<String, dynamic> ref,
  Map<String, dynamic> argument,
  Map<String, dynamic>? context,
);