Skip to content

fix(mcp): follow nextCursor in prompts/list, resources/list and resources/templates/list - #859

Open
yudongyouqing wants to merge 1 commit into
EverMind-AI:mainfrom
yudongyouqing:fix/mcp_list_pagination
Open

yudongyouqing wants to merge 1 commit into
EverMind-AI:mainfrom
yudongyouqing:fix/mcp_list_pagination

Conversation

@yudongyouqing

Copy link
Copy Markdown
Contributor

Summary

  • New raven/mcp/paging.py walks a paginated list verb page by page with params=PaginatedRequestParams(cursor=...), stopping on an absent or a repeated cursor (the rule fix(mcp): page through tools/list nextCursor #825 introduced for tools/list). The public surface is one typed walker per verb (walk_tools / walk_resources / walk_resource_templates / walk_prompts), so the items a caller loops over carry their real SDK type rather than the Any a session yields at these call sites; the page shape stays behind one private engine.
  • The three remaining verbs now walk through it: resources/list and resources/templates/list in raven/mcp/resources.py, and prompts/list in raven/mcp/prompts.py. Each site keeps its existing _with_timeout around the whole walk, so a server that never stops paging fails visibly instead of stalling the turn.
  • The tools/list loop from fix(mcp): page through tools/list nextCursor #825 in raven/mcp/client.py collapses onto the same helper, so all four verbs share one implementation.
  • Design note, for the author to settle: the module exposes one typed walker per verb over a single private engine, rather than one generic helper. Typed returns give the items their real SDK type (IDE completion, and future-proof the day an attribute rule switches on); under the repo's current ty config, a call-correctness gate with unresolved-attribute off, both shapes pass identically, and collapsing the wrappers into one generic helper is a small change if that reads better.
  • Single-page behaviour is unchanged: existing tests pass without modification beyond the fakes accepting the params argument the walker always passes.

Type

  • Fix

Verification

  • Relevant tests pass locally: uv run pytest tests/test_mcp_resources.py tests/test_mcp_prompts.py tests/test_mcp_client.py tests/test_mcp_manager.py -> 88 passed, including four new tests (multi-page resources, multi-page templates, repeated cursor, multi-page prompts)
  • The new tests fail on current main: stashing only the raven/ changes and running them -> 4 failed; restoring the fix -> pass
  • Relevant lint / type checks pass locally: ruff check + ruff format --check on the touched files; ty check at the pre-change baseline (18 platform-only diagnostics on Windows, no new); lint-imports -> 10 contracts kept, 0 broken
  • User-facing docs or screenshots are updated when needed: not needed, no user-visible copy changes

Risk

  • Security impact considered: reads more of what a server already serves; no new inputs, credentials or surfaces
  • Backward compatibility considered: single-page servers answer one request exactly as before, and the repeated-cursor stop rule is the one fix(mcp): page through tools/list nextCursor #825 already shipped for tools
  • Rollback path is clear: plain revert restores the single-page behaviour

Related Issues

Fixes #855

This branch has not been deployed

No deployments
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(mcp): follow nextCursor in prompts/list, resources/list and resources/templates/list

1 participant