{"record":{"id":"3d4b5b199635dfb9","repo":"PrefectHQ/fastmcp","slug":"self-name-reached-auto-pagination-limit-max","errorCode":null,"errorMessage":"[{self.name}] Reached auto-pagination limit ({max_pages} pages) for list_prompts. Use list_prompts_mcp() with cursor for manual pagination, or increase max_pages.","messagePattern":"\\[(.+?)\\] Reached auto-pagination limit \\((.+?) pages\\) for list_prompts\\. Use list_prompts_mcp\\(\\) with cursor for manual pagination, or increase max_pages\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"fastmcp_slim/fastmcp/client/mixins/prompts.py","lineNumber":110,"sourceCode":"        all_prompts: list[mcp_types.Prompt] = []\n        cursor: str | None = None\n        seen_cursors: set[str] = set()\n\n        for _ in range(max_pages):\n            result = await self.list_prompts_mcp(cursor=cursor)\n            all_prompts.extend(result.prompts)\n            if not result.next_cursor:\n                break\n            if result.next_cursor in seen_cursors:\n                logger.warning(\n                    f\"[{self.name}] Server returned duplicate pagination cursor\"\n                    f\" {result.next_cursor!r} for list_prompts; stopping pagination\"\n                )\n                break\n            seen_cursors.add(result.next_cursor)\n            cursor = result.next_cursor\n        else:\n            raise RuntimeError(\n                f\"[{self.name}] Reached auto-pagination limit\"\n                f\" ({max_pages} pages) for list_prompts.\"\n                \" Use list_prompts_mcp() with cursor for manual pagination,\"\n                \" or increase max_pages.\"\n            )\n\n        return all_prompts\n\n    # --- Prompt ---\n    async def get_prompt_mcp(\n        self: Client,\n        name: str,\n        arguments: dict[str, Any] | None = None,\n        meta: dict[str, Any] | None = None,\n    ) -> mcp_types.GetPromptResult:\n        \"\"\"Send a prompts/get request and return the complete MCP protocol result.\n\n        Args:","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/PrefectHQ/fastmcp/blob/1f021142978e0861cd910c8df4e8074bc7cf3978/fastmcp_slim/fastmcp/client/mixins/prompts.py#L92-L128","documentation":"FastMCP's client `list_prompts()` auto-paginates through the server's prompt list, following `nextCursor` for up to `max_pages` iterations (default 250, `AUTO_PAGINATION_MAX_PAGES`). If the cursor chain does not terminate within that budget, the for-else branch raises `RuntimeError` instead of looping forever. It is a safety guard against runaway or non-terminating pagination, not a server failure.","triggerScenarios":"Calling `client.list_prompts()` (or the internal `_send` path) against a server that returns more than 250 pages of prompts, or a misbehaving server whose `nextCursor` never becomes None (e.g. a cursor that repeats or is always regenerated).","commonSituations":"Connecting to a proxy/gateway server that exposes a very large upstream prompt catalog split into tiny pages; a buggy third-party MCP server that fails to terminate its cursor chain; a page size of ~1 item on a server with hundreds of prompts.","solutions":["Use the low-level `client.list_prompts_mcp(cursor=...)` and iterate manually, stopping when `result.next_cursor is None`.","Raise the budget: `client.list_prompts(max_pages=...)` with a larger value.","Fix or avoid the server that emits non-terminating cursors; verify with `list_prompts_mcp()` whether the same cursor is repeated.","Reduce the number of prompts on the server or ask the server to return larger pages."],"exampleFix":"// before\nprompts = await client.list_prompts()  # RuntimeError after 250 pages\n// after\nresult = await client.list_prompts_mcp()\nprompts = result.prompts\nwhile result.next_cursor is not None:\n    result = await client.list_prompts_mcp(cursor=result.next_cursor)\n    prompts.extend(result.prompts)","handlingStrategy":"try-catch","validationCode":"# Probe pagination health before the auto-paginating call\nfirst = await client.list_prompts_mcp()\nif first.next_cursor is not None and len(first.prompts) < 10:\n    print(\"Server pages are small; prefer manual pagination or larger max_pages\")","typeGuard":null,"tryCatchPattern":"try:\n    prompts = await client.list_prompts()\nexcept RuntimeError as e:\n    if \"auto-pagination limit\" not in str(e):\n        raise\n    # fall back to manual pagination\n    page = await client.list_prompts_mcp()\n    prompts = page.prompts\n    cursor = page.next_cursor\n    while cursor is not None:\n        page = await client.list_prompts_mcp(cursor=cursor)\n        prompts.extend(page.prompts)\n        cursor = page.next_cursor","preventionTips":["Use list_prompts_mcp() with an explicit loop when the server is known to have large catalogs","Pass an explicit max_pages sized to the expected catalog size (pages, not items)","Log next_cursor values when debugging so a repeating (broken) cursor is obvious","Watch for servers that emit a cursor even on the final page"],"tags":["pagination","client","mcp","runtime-error"],"backgroundTag":"pagination-limit-exceeded","analyzedSha":"1f021142978e0861cd910c8df4e8074bc7cf3978","analyzedAt":"2026-08-29T14:31:16.082Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}