-
Notifications
You must be signed in to change notification settings - Fork 625
Description
When listing tools, the MCP spec allows for pagination so that if there are a large number of tools, all the information can be split across several requests rather than returned all in one request.
Pagination is controlled by the server, so we decide how many results to return, and what the cursor is.
Probably the easiest thing to do would be to make the cursor the name of the last tool returned. As long as the list of tools remains the same, if the user provides a cursor, we go down the list until we find the corresponding tool and then start our result from the next one.
We will need to pick a page size. 20 seems reasonable as a starting point. In the future we might make it configurable, but I don't think we need to do that now.
We will need to update existing tests which call tools/list which receive a result larger than our page size. We can avoid changing the existing tests too much by making multiple requests and then sticking the results together. I think it would make sense to add a method to McpClient to call tools/list as many times as necessary and collect all the results.