π The fast, Pythonic way to build MCP servers and clients.
Bound Skills proxy backend pagination (#6104)
prassu0172938609d9c56
diff --git a/fastmcp_slim/fastmcp/skills/_proxy.py b/fastmcp_slim/fastmcp/skills/_proxy.pyindex 709541e14..4a3386b9b 100644--- a/fastmcp_slim/fastmcp/skills/_proxy.py+++ b/fastmcp_slim/fastmcp/skills/_proxy.py@@ -11,6 +11,7 @@ from mcp.shared.exceptions import MCPErrorfrom mcp_types import INVALID_PARAMS, METHOD_NOT_FOUNDfrom fastmcp.client.client import Client+from fastmcp.client.mixins.skills import AUTO_PAGINATION_MAX_PAGESfrom fastmcp.server.dependencies import get_contextfrom fastmcp.server.providers.base import Providerfrom fastmcp.server.providers.proxy import (@@ -102,7 +103,7 @@ class _ProxiedSkills:cursor: str | None = Noneseen: set[str] = set()async with self._client() as client:- while True:+ for _ in range(AUTO_PAGINATION_MAX_PAGES):request = ListSkillsRequest(params=ListSkillsParams(cursor=cursor, meta=meta))@@ -119,6 +120,10 @@ class _ProxiedSkills:return entriesseen.add(page.next_cursor)cursor = page.next_cursor+ raise RuntimeError(+ f"Reached auto-pagination limit ({AUTO_PAGINATION_MAX_PAGES} pages) "+ "listing the backend's skills"+ )async def _get_backend(self, uri: str) -> MCPSkill | None:meta = _session_request_meta(_forwardable_request_meta(get_context()))diff --git a/tests/server/providers/proxy/test_skills.py b/tests/server/providers/proxy/test_skills.pyindex 4dfae5b12..424229036 100644--- a/tests/server/providers/proxy/test_skills.py+++ b/tests/server/providers/proxy/test_skills.py@@ -144,6 +144,33 @@ async def test_follows_backend_pagination() -> None:]+class ListSkillsRequests(Middleware):+ def __init__(self) -> None:+ self.count = 0++ async def on_request(self, context, call_next):+ if context.method == "skills/list":+ self.count += 1+ return await call_next(context)+++async def test_backend_pagination_is_bounded(monkeypatch: pytest.MonkeyPatch) -> None:+ # raising=False keeps this a behavioral failure on code without the bound.+ monkeypatch.setattr(+ "fastmcp.skills._proxy.AUTO_PAGINATION_MAX_PAGES", 1, raising=False+ )+ upstream = backend(REVIEW, DEPLOY, page_size=1)+ requests = ListSkillsRequests()+ upstream.add_middleware(requests)+ server = gateway(upstream)+ server.provider_error_strategy = "raise"++ async with skills_client(server) as client:+ with pytest.raises(MCPError):+ await client.list_skills()+ assert requests.count == 1++async def test_local_and_proxied_skills_share_one_catalog() -> None:server = gateway(backend(REVIEW))server.add_provider(SkillCatalogProvider([DEPLOY]))