Repository navigation
Stop listRoots pagination on an empty nextCursor - #1276
Open
JunyangLian wants to merge 1 commit into
Open
JunyangLian wants to merge 1 commit into
JunyangLian wants to merge 1 commit into
Conversation
McpAsyncServerExchange#listRoots() kept requesting roots/list while a client reported nextCursor as an empty string, so the aggregated call never completed and the sync exchange blocked forever. End pagination on an empty cursor, matching the client-side guard in McpAsyncClient, and add a regression test.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
McpAsyncServerExchange#listRoots()followsnextCursoruntil it isnull. A client that answersroots/listwith"nextCursor": ""instead of omitting the field makes the aggregate call request page after page, andMcpSyncServerExchange#listRoots()blocks forever.The client-side aggregate methods already stop on
next != null && !next.isEmpty()(see #954); this applies the same guard to the server exchange, which the issue calls out as the last aggregate list method without it.Changes
nullor emptynextCursorinMcpAsyncServerExchange#listRoots().testListRootsStopsPagingOnEmptyNextCursor, which serves a second page carryingnextCursor: ""and asserts exactly tworoots/listrequests. Without the guard the expander returns a null publisher for the third request and the test fails.Tests
./mvnw -pl mcp-core test -Dtest=McpAsyncServerExchangeTests-> 38 tests, 0 failures.Fixes #1274