fix(mcp): page through tools/list nextCursor - #825
Conversation
A server that exposes more tools than its page size silently lost every tool after the first page: the connection fetched tools/list once and never followed nextCursor. The agent-browser "all" profile exceeds one 64-tool page, so only the first page registered. The connection now keeps requesting with the returned cursor until the server stops paging, and a repeated cursor stops the loop rather than paging forever.
|
Thanks for the fix -- following R1 (blocking)
Fix -- extend the local import at line 252 and pass the cursor through from mcp import ClientSession, types
...
page = await session.list_tools(params=types.PaginatedRequestParams(cursor=cursor))The three test fakes that take
async def list_tools(self, *, params=None):
cursor = params.cursor if params else NoneVerify: |
Address the review on EverMind-AI#825: the `list_tools(cursor=...)` overload is deprecated in the pinned mcp 1.30.0, and the ty gate exits non-zero on warnings, so `make lint-types` fails. Pass the cursor via `params=types.PaginatedRequestParams(cursor=cursor)` instead, and teach the three session fakes to take `params`. Co-Authored-By: Claude Code <noreply@anthropic.com>
|
Thanks for the precise pointer. Addressed in e13ea4d: the call now goes through |
Address the review on EverMind-AI#825: the `list_tools(cursor=...)` overload is deprecated in the pinned mcp 1.30.0, and the ty gate exits non-zero on warnings, so `make lint-types` fails. Pass the cursor via `params=types.PaginatedRequestParams(cursor=cursor)` instead, and teach the three session fakes to take `params`.
9620620 to
e13ea4d
Compare
|
Merged in 5be9698 -- thanks @yudongyouqing! Servers that page |
Summary
tools/listresponses may be paginated with anextCursor; the connection fetched the list once and registered only the first page, silently dropping every tool beyond the server's page size (fix: handle paginated MCP tools/list responses #301)._mcp_server_connectionnow keeps requestingtools/listwith the returned cursor until the server stops paging, and yields the accumulated tool list. A repeated cursor stops the loop, so a misbehaving server cannot page forever.raven/mcp/client.pylayout. That PR was auto-closed by the 2026-09-12 history rewrite, not by review; the analysis and repro in fix: handle paginated MCP tools/list responses #301 carry over unchanged.Type
Verification
Commands run on macOS, Python 3.12, on top of a clean checkout of main:
uv run pytest tests/test_mcp_client.py tests/test_mcp_client_transport.py tests/test_mcp_manager.py tests/test_mcp_bridge.py tests/test_mcp_change_probe.py tests/test_mcp_endpoint.py tests/test_mcp_naming.py tests/test_mcp_prompts.py tests/test_mcp_resources.py tests/test_mcp_session_addressing.py tests/test_agent_loop_mcp_meta_tools.py tests/test_agent_loop_mcp_sync.py tests/test_acp_per_session_mcp.py tests/test_cli_mcp_commands.py tests/test_sandbox_unit.py -q-> 357 passed.tests/test_mcp_client.pywere each watched failing before the fix: two pages register every tool; a repeated cursor terminates paging.uv run --frozen --python 3.12 --all-extras pytest -q-> 26998 passed, 109 skipped, 21 failed. The 21 failures are the same set that fails on unmodified main in this environment (verified by stashing this change):test_agents_research_tools.py(13),test_agents_research_verbatim_sink.py(5),test_simulation_scenario.pyandtest_simulation_suite.py(2),test_rpc_files.py::test_a_host_without_libreoffice_says_so(1, LibreOffice not installed locally). None touch the changed modules.uv run ruff checkandruff format --checkon the four touched files -> clean.make lint-imports-> 10 kept, 0 broken.Risk
Security impact considered
Backward compatibility considered
Rollback path is clear for risky changes
No wire or config change. A server that does not paginate (
nextCursorabsent or None) behaves exactly as before; the repeated-cursor guard is the only new stop condition, and it only fires where the old code would have registered one page and moved on.Rollback is a straight revert of this commit.
Related Issues
Fixes #301