listResourceTemplates method

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

List resource templates on the server

Implementation

Future<List<ResourceTemplate>> listResourceTemplates({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 = <ResourceTemplate>[];
  final seen = <String>{};
  String? cursor;
  do {
    final page = await listResourceTemplatesPage(cursor: cursor, meta: meta, options: options);
    all.addAll(page.resourceTemplates);
    cursor = page.nextCursor;
    if (cursor != null && !seen.add(cursor)) {
      throw McpError('`resources/templates/list` repeated cursor "$cursor"');
    }
  } while (cursor != null);
  return all;
}