265
*/
266
private async *sendRequestPaginated<T extends MCP.PaginatedRequest & MCP.ClientRequest, R extends MCP.PaginatedResult, I>(method: T['method'], getItems: (result: R) => I[], initialParams?: Omit<T['params'], 'jsonrpc' | 'id'>, token: CancellationToken = CancellationToken.None): AsyncIterable<I[]> {
268
>
269
>
do {
270
>
const params: T['params'] = {
271
>
...initialParams,
272
>
cursor: nextCursor
273
>
};
274
>
275
>
const result: R = await this.sendRequest<T, R>({ method, params }, token);
276
yield getItems(result);
277
nextCursor = result.nextCursor;
279
>
}
280
281
private sendNotification<N extends MCP.ClientNotification>(notification: Omit<N, 'jsonrpc'>): void {