listTools method

Future<McpStreamableToolListPage> listTools({
  1. Object? id,
  2. String? cursor,
  3. bool streamable = true,
  4. String? protocolVersion,
  5. Map<String, String> headers = const <String, String>{},
})

Lists one page of tools through the active MCP session.

Implementation

Future<McpStreamableToolListPage> listTools({
  Object? id,
  String? cursor,
  bool streamable = true,
  String? protocolVersion,
  Map<String, String> headers = const <String, String>{},
}) async {
  const method = 'tools/list';
  final requestGeneration = _claimToolCatalogRequestGeneration();
  final response = await request(
    method,
    id: id,
    params: _cursorParams(cursor),
    streamable: streamable,
    protocolVersion: protocolVersion,
    headers: headers,
  );
  final result = _jsonRpcResultFrom(response, method: method);
  final catalogTools = _validatedToolCatalogEntries(
    _jsonMapListFrom(
      result,
      key: 'tools',
      method: method,
      label: '$method result tool',
    ),
    label: '$method result tool',
  );
  final nextCursor = _nextCursorFrom(result, method: method);
  final tools = _rememberToolHeaderParameters(
    catalogTools,
    requestGeneration: requestGeneration,
  );
  return McpStreamableToolListPage(tools: tools, nextCursor: nextCursor);
}