Repository navigation
Description
Peer<RoleClient>::list_all_tools, list_all_prompts, list_all_resources, list_all_resource_templates, and list_all_skills (crates/rmcp/src/service/client.rs) loop until next_cursor is None. Nothing else stops them.
loop {
let result = self
.list_tools(Some(PaginatedRequestParams { meta: None, cursor }))
.await?;
tools.extend(result.tools);
cursor = result.next_cursor;
if cursor.is_none() {
break;
}
}The same loop is copied for the other four methods. These are the helpers the examples and the Python/JS interop tests call to load a server.
Why it matters
The 2026-07-28 pagination rules say a client treats a missing nextCursor as the end of the results, and that it must not decide anything else from the cursor value. An empty string is explicitly a valid cursor. A server that keeps the field present — "", the same token again, or a fresh token every page — makes list_all_* run until the process runs out of memory. Each iteration appends another page first, so the Vec grows without bound.
That is a realistic peer, not only a hostile one. The C# SDK hit non-terminating tools/list walks in csharp-sdk#988 and csharp-sdk#1072. The TypeScript client used to stop when a cursor repeated, which silently dropped pages, and typescript-sdk#2736 removed that check. It still fails the walk with ListPaginationExceeded after listMaxPages.
A positive ttlMs makes the Rust walk worse. list_tools / list_prompts / list_resources / list_resource_templates cache a page under a key that is only the cursor (list_response_cache_key). ttlMs: 0 is not stored (ClientCacheConfig::default_ttl is zero, and cache_response_with_generation skips a zero TTL), but the spec's own example uses ttlMs: 300000. Once a repeated cursor is cached, later iterations never reach the server: they append the cached page again in a tight loop. list_all_skills is not cached, so that one stays a network loop.
What not to do
Do not treat "" or a repeated cursor as the end. The spec forbids that, and the TypeScript SDK already shipped a bug by stopping on a repeated opaque cursor.
Suggestion
Bound the walk, the same way MRTR is already bounded.
call_tool_with_mrtr_max_rounds stops after DEFAULT_MRTR_MAX_ROUNDS and returns ServiceError::InputRequiredRoundsExceeded. A list_all_* walk needs the same shape: a finite default, an override, and a ServiceError variant that names the cap. Check the cap on cache hits too, so a cached repeated cursor cannot spin. Keep requesting while next_cursor is Some, including Some("").
skills/list is not in the core pagination section, but list_all_skills has the same loop and should share the cap.
Activity
github-actions commentedon Nov 14, 2026
@jokemanfire is on triage rotation this week and is the reviewer for this one.
Codex labeled this bug / P0 (T-service, T-security). Please confirm or correct those labels.
Automated triage. Labels are a first pass and the assigned maintainer has the final say.
docs(client): document the list_all_* page cap
marcus-beauregard commentedon Nov 20, 2026
Opened #1479 with a cap on the walk:
DEFAULT_LIST_MAX_PAGES = 64inmodel.rs, counted in the sharedlist_all_pagesloop so cached responses count too, and a newServiceError::ListPaginationExceededinstead of growing the merged list. Each helper keeps its signature and gains a*_with_max_pagesoverride.Four unit tests cover the looping cursor, the default,
Some("")as a valid cursor, and an explicit shorter cap — all driven through the response cache on a disconnected peer, so no server needed.It is open as a draft because this account is currently refused
markPullRequestReadyForReviewby the API; the diff and description are complete and it is ready for review as-is.fix(client): cap list_all_* pagination like the MRTR round cap
docs(client): document the list_all_* page cap