mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-21 16:18:55 +00:00
fix(mcp): treat non-string nextCursor as end of pagination
Per the MCP spec the cursor is an opaque string; anything else (including MagicMock auto-attributes in tests) means no more pages. Fixes test_mcp_tool_session_expired mock-session runaway.
This commit is contained in:
parent
6030ca8cea
commit
a8ec41533c
1 changed files with 3 additions and 1 deletions
|
|
@ -609,7 +609,9 @@ async def _paginate_full_list(list_method, items_attr: str, server_name: str):
|
|||
result = await (list_method(cursor=cursor) if cursor else list_method())
|
||||
items.extend(getattr(result, items_attr, None) or [])
|
||||
cursor = getattr(result, "nextCursor", None)
|
||||
if not cursor:
|
||||
# Per the MCP spec the cursor is an opaque string; anything else
|
||||
# (including mock objects in tests) means "no more pages".
|
||||
if not isinstance(cursor, str) or not cursor:
|
||||
break
|
||||
else:
|
||||
logger.warning(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue