listTools method

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

List available tools on the server

Implementation

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