preserve tool listing post-processing

This commit is contained in:
kigland 2026-10-26 10:41:46 +08:00
parent 01013b7e33
commit 4c52080152
2 changed files with 9 additions and 0 deletions

View file

@ -134,6 +134,14 @@ async def list_tools_with_pagination(
ListToolsRequest(params=params),
_LenientListToolsResult,
)
# ClientSession.list_tools() normally performs this post-processing
# after decoding: it filters invalid x-mcp-header annotations and
# records the derived header/output-schema state used by tools/call.
# Keep those semantics when injecting the lenient result model.
result = session._absorb_tool_listing(
result,
complete=cursor is None and result.next_cursor is None,
)
tools.extend(result.tools)
next_cursor = result.next_cursor

View file

@ -46,6 +46,7 @@ def mock_session():
return await session.list_tools()
session.send_request = AsyncMock(side_effect=send_request)
session._absorb_tool_listing.side_effect = lambda result, **_kwargs: result
return session