Skip to content

fix: stop pagination on empty cursors - #954

Merged
Kehrlann merged 1 commit into
modelcontextprotocol:mainfrom
nanookclaw:fix/empty-pagination-cursors
Aug 7, 2026
Merged

fix: stop pagination on empty cursors#954
Kehrlann merged 1 commit into
modelcontextprotocol:mainfrom
nanookclaw:fix/empty-pagination-cursors

Conversation

@nanookclaw

Copy link
Copy Markdown
Contributor

Summary

Fixes #575.

listTools() already treats an empty nextCursor as the end of pagination. This applies the same guard to the other async aggregate list methods so servers that return "" instead of null do not trigger a repeated request with an empty cursor.

The change covers listResources(), listResourceTemplates(), and listPrompts(), and adds regression tests that verify each method stops after the first response when nextCursor is empty.

Testing

  • ./mvnw -pl mcp-core,mcp-test spring-javaformat:validate
  • git diff --check

I also tried ./mvnw -pl mcp-test -am -Dtest=McpAsyncClientTests test, but this environment has only a JRE installed (javac is missing), so Maven fails before running tests with release version 17 not supported. A baseline compile on unmodified HEAD fails the same way locally.

@Kehrlann Kehrlann added this to the 2.0.1 milestone Aug 7, 2026
Signed-off-by: Nanook <nanookclaw@users.noreply.github.com>
@Kehrlann
Kehrlann force-pushed the fix/empty-pagination-cursors branch from e18d0fa to 8873da1 Compare August 7, 2026 14:13
@Kehrlann
Kehrlann merged commit 27b9152 into modelcontextprotocol:main Aug 7, 2026
45 of 61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The method io.modelcontextprotocol.client.McpAsyncClient#listTools() never returns if the result.nextCursor() is an empty string instead of a null

2 participants