-
Notifications
You must be signed in to change notification settings - Fork 700
Description
Bug description
Even though the implementation uses a loop to fetch tools based on the next cursor value, the API is being called only once and returns all MCP tools (more than 200) in a single response. This indicates that pagination is not functioning as expected.
Environment
- Spring MCP version: LATEST
- Java version: 17
Steps to reproduce
-
Deploy the MCP server with more than 200 tools registered.
-
Use the following code snippet to fetch tools:
public List<McpSchema.Tool> listTools(final McpSyncClient mcpSyncClient) {
final List<McpSchema.Tool> tools = new ArrayList<>();
String cursor = null;
do {
final ListToolsResult listToolsResult = mcpSyncClient.listTools(cursor);
final List<Tool> toolList = listToolsResult.tools();
log.info("toolList size: {}", toolList.size());
tools.addAll(toolList);
cursor = listToolsResult.nextCursor();
} while (cursor != null);
return tools;
}
- Observe the logs and behavior.
Expected behavior
-
The mcpSyncClient.listTools(cursor) API should be called multiple times until all tools are fetched.
-
Each API call should return a limited subset of tools (based on page size), and the nextCursor should guide the next request.
-
Pagination should be configurable (e.g., pageSize or limit parameter) so users can control how many tools are fetched per request.
Minimal Complete Reproducible example
A minimal example can be created by:
-
Setting up an MCP server with more than 200 registered tools.
-
Running the above Java method to fetch tools.
-
Observing that only one API call is made (indicating that nextCursor is not working as intended).
Observed result:
- One call to /tools/list returning all tools.
Expected result:
- Multiple paginated calls to /tools/list, each returning a subset of tools until all are fetched.
Additional questions
-
How many tools are expected to be fetched in a single request by default?
-
Is this page size configurable from client-side?