listPrompts method

Future<List<Prompt>> listPrompts({
  1. Map<String, dynamic>? meta,
  2. RequestOptions? options,
})

List available prompts on the server

Implementation

Future<List<Prompt>> listPrompts({Map<String, dynamic>? meta, RequestOptions? options}) async {
  // Every page: the server decides the page size and signals more with
  // `nextCursor` (an empty string is a cursor, not the end).
  final all = <Prompt>[];
  final seen = <String>{};
  String? cursor;
  do {
    final page = await listPromptsPage(cursor: cursor, meta: meta, options: options);
    all.addAll(page.prompts);
    cursor = page.nextCursor;
    if (cursor != null && !seen.add(cursor)) {
      throw McpError('`prompts/list` repeated cursor "$cursor"');
    }
  } while (cursor != null);
  return all;
}