fix: follow nextCursor when listing MCP tools - #65
Open
airidasbrikas23 wants to merge 1 commit into
Open
Conversation
session.list_tools() only returns one page; on any MCP server whose tool count exceeds the page size, everything past page 1 was silently missing from --list and from the generated CLI subcommands, with no error or warning. tools/list is a paginated operation per the MCP spec (page size is up to the server, clients should loop until nextCursor is absent): https://modelcontextprotocol.io/specification/2025-06-18/server/utilities/pagination Adds _list_all_tools(), a shared helper that loops on cursor until exhausted, and routes all three session.list_tools() call sites through it. Reproduced against a real server (stimmt/craft-mcp, a Craft CMS MCP server) that pages at 50: a 54-tool connection was missing its last 4 tools before this fix.
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.
Fixes #64.
`session.list_tools()` only returns one page; on any MCP server whose tool count exceeds the page size, everything past page 1 was silently missing from `--list` and from the generated CLI subcommands, with no error or warning.
`tools/list` is a paginated operation per the MCP spec — page size is up to the server, and clients should loop until `nextCursor` is absent:
Changes
Verified against a real paginated server: stimmt/craft-mcp (a Craft CMS MCP server) pages `tools/list` at 50. Before this fix, a 54-tool connection was missing its last 4 tools (`get_entry`, `create_entry`, `update_entry`, `describe_entry_schema`) from `--list` with zero indication anything was wrong; after, all 54 show up and are callable.
Full test suite passes (355 tests, no regressions).