Skip to content

Commit 2b0429b

Browse files
fix: pagination nextCursor is empty strings (#250)
Pagination spec: https://modelcontextprotocol.io/specification/2025-06-18/server/utilities/pagination Pagination nextCurour compatible with None or empty strings. Prevent reaching MAX_ITERATIONS, some third-party MCP service implementations​. nextCursor is empty strings. e.g., higress: https://github.com/alibaba/higress/blob/main/plugins/golang-filter/mcp-session/common/server.go#L624-L627
1 parent 49a13ec commit 2b0429b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

langchain_mcp_adapters/tools.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ async def _list_all_tools(session: ClientSession) -> list[MCPTool]:
8383
if list_tools_page_result.tools:
8484
all_tools.extend(list_tools_page_result.tools)
8585

86-
if list_tools_page_result.nextCursor is None:
86+
# Pagination spec: https://modelcontextprotocol.io/specification/2025-06-18/server/utilities/pagination
87+
# compatible with None or ""
88+
if not list_tools_page_result.nextCursor:
8789
break
8890

8991
current_cursor = list_tools_page_result.nextCursor

0 commit comments

Comments
 (0)