Skip to content

Commit e13ea4d

Browse files
committed
fix(mcp): pass the tools/list cursor through PaginatedRequestParams
Address the review on #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`.
1 parent af4ee28 commit e13ea4d

4 files changed

Lines changed: 6 additions & 5 deletions

File tree

‎raven/mcp/client.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ async def _mcp_server_connection(
249249
cancels the turn that was connecting.
250250
"""
251251
async with AsyncExitStack() as stack:
252-
from mcp import ClientSession
252+
from mcp import ClientSession, types
253253

254254
read, write = await stack.enter_async_context(
255255
open_mcp_transport(cfg, transport_type, executor, http_auth=http_auth)
@@ -262,7 +262,7 @@ async def _mcp_server_connection(
262262
cursor = None
263263
seen_cursors = set()
264264
while True:
265-
page = await session.list_tools(cursor=cursor)
265+
page = await session.list_tools(params=types.PaginatedRequestParams(cursor=cursor))
266266
tools.extend(page.tools)
267267
cursor = page.nextCursor
268268
# A server that keeps returning the same cursor would page forever.

‎tests/test_mcp_client.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ async def __aexit__(self, exc_type, exc, traceback):
105105
async def initialize(self):
106106
return SimpleNamespace(capabilities=SimpleNamespace(tools=True))
107107

108-
async def list_tools(self, cursor=None):
108+
async def list_tools(self, *, params=None):
109+
cursor = params.cursor if params else None
109110
asked.append(cursor)
110111
return pages[cursor]
111112

‎tests/test_mcp_manager.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ async def initialize(self):
278278
await asyncio.Event().wait()
279279
return SimpleNamespace(capabilities=SimpleNamespace(tools=True))
280280

281-
async def list_tools(self, cursor=None):
281+
async def list_tools(self, *, params=None):
282282
return SimpleNamespace(
283283
tools=[SimpleNamespace(name="ping", description="", inputSchema={})], nextCursor=None
284284
)

‎tests/test_sandbox_unit.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,7 @@ async def __aexit__(self, exc_type, exc, traceback):
18011801
async def initialize(self):
18021802
return SimpleNamespace(capabilities=SimpleNamespace(tools=object()))
18031803

1804-
async def list_tools(self, cursor=None):
1804+
async def list_tools(self, *, params=None):
18051805
return SimpleNamespace(tools=[], nextCursor=None)
18061806

18071807
monkeypatch.setattr(httpx, "AsyncClient", fake_http_client)

0 commit comments

Comments
 (0)