Skip to content

fix(tools): page through MCP tools/list nextCursor - #302

Open
icn5381 wants to merge 1 commit into
EverMind-AI:mainfrom
icn5381:fix/mcp_tools_list_pagination
Open

fix(tools): page through MCP tools/list nextCursor#302
icn5381 wants to merge 1 commit into
EverMind-AI:mainfrom
icn5381:fix/mcp_tools_list_pagination

Conversation

@icn5381

@icn5381 icn5381 commented Aug 12, 2026

Copy link
Copy Markdown

Summary

connect_mcp_servers called list_tools() once and registered only the tools on the first page. A server that paginates tool discovery (returns a nextCursor) silently exposed a partial tool surface: every tool past the first page was omitted with no error.

Follow nextCursor page to page until the server stops returning one, then register the full set. Track seen cursors so a misbehaving server that re-issues the same cursor cannot trap discovery in a loop.

The paging loop lives in a new _collect_tools helper so it is unit-testable without standing up a transport/registry.

Type

  • Fix

Verification

  • Relevant tests pass locally: uv run pytest tests/test_mcp_tools_pagination.py -v -> 3 passed
  • Relevant lint / type checks pass locally: uv run ruff format (2 files unchanged), uv run ruff check (all passed)
  • User-facing docs or screenshots updated: N/A (internal discovery fix)

Risk

  • Security impact considered: no new code path beyond iterating a cursor the server already returns; no shell, no network egress change
  • Backward compatibility considered: single-page servers (no nextCursor) hit the same one-iteration path as before
  • Rollback path is clear: revert restores the single list_tools() call

Related Issues

Fixes #301

connect_mcp_servers called list_tools() once and registered only the
first page, so any MCP server that paginates tool discovery silently
exposed a partial tool surface. Follow nextCursor page to page until
the server stops returning one, guarding against a repeated cursor
trapping discovery in a loop.

Co-authored-by: Claude (claude-opus-5) <noreply@anthropic.com>
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.

fix: handle paginated MCP tools/list responses

1 participant