listPrompts method

Future<McpStreamablePromptListPage> listPrompts({
  1. Object? id,
  2. String? cursor,
  3. bool streamable = true,
  4. bool directJson = false,
  5. String? protocolVersion,
  6. Map<String, String> headers = const <String, String>{},
})

Lists one page of prompts through the active MCP session.

Implementation

Future<McpStreamablePromptListPage> listPrompts({
  Object? id,
  String? cursor,
  bool streamable = true,
  bool directJson = false,
  String? protocolVersion,
  Map<String, String> headers = const <String, String>{},
}) async {
  final response = await request(
    'prompts/list',
    id: id,
    params: _cursorParams(cursor),
    streamable: directJson ? false : streamable,
    includeSession: !directJson,
    protocolVersion: protocolVersion,
    headers: headers,
  );
  final result = _jsonRpcResultFrom(response, method: 'prompts/list');
  return McpStreamablePromptListPage(
    prompts: _validatedPromptCatalogEntries(
      _jsonMapListFrom(
        result,
        key: 'prompts',
        method: 'prompts/list',
        label: 'prompts/list result prompt',
      ),
      label: 'prompts/list result prompt',
    ),
    nextCursor: _nextCursorFrom(result, method: 'prompts/list'),
  );
}