litellm/tests/mcp_tests
yucheng-berri 5767a2da0f
fix(mcp): follow tools/list pagination from upstream servers (#39172)
* fix(mcp): follow tools/list pagination from upstream servers

Adopts BerriAI/litellm#32244 by Jupiter363 onto litellm_internal_staging
with merge conflicts resolved

* fix(mcp): degrade buggy pagination to partial results and bound the preview walk

A repeated nextCursor now returns the tools collected so far instead of
discarding every page with a RuntimeError, an empty-string cursor is treated
as terminal, load_mcp_tools shares the same pagination walk instead of
returning only the first page, and the tools/list preview is bounded by the
listing timeout instead of only the per-request timeout times the page cap

* fix(mcp): annotate deliberate rebind for the preview timeout scope

* fix(mcp): bound the shared pagination walk with an overall listing deadline

The per-request session read timeout restarts on every page, so direct SDK
callers of list_tools and load_mcp_tools could run up to the page cap with
no overall bound. The walk now returns the tools collected so far when
max(MCP_CLIENT_TIMEOUT, MCP_TOOL_LISTING_TIMEOUT) expires

* fix(mcp): let a per-server timeout extend the pagination deadline

MCPClient carries a per-server timeout that can exceed the global default;
list_tools now passes max(self.timeout, MCP_TOOL_LISTING_TIMEOUT) into the
shared walk so a deliberately slow server is not silently truncated at the
global deadline

* fix(mcp): honor per-server timeouts in the preview deadline and test the walk sessionless

The preview deadline now extends with the created client's own timeout, and
the pagination walk's cap, repeated-cursor, and empty-cursor cases are tested
directly against the helper instead of through patched SDK internals

* fix(mcp): forward the preview request's per-server timeout to the temporary server model

The tools preview built its temporary MCPServer without the request's
timeout field, so the client factory always fell back to the global
default and a per-server timeout could never extend the preview's
listing deadline (or its per-request timeout).
2026-09-01 14:34:14 -07:00
..
test_configs [Release Fix] (#22411) 2026-02-28 09:46:35 -08:00
conftest.py Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_deflake_20260821 2026-08-27 09:17:37 +00:00
mcp_e2e_upstream_server.py test(e2e): mcp suite for key-without-access denial (#33752) 2026-07-17 16:04:43 -07:00
mcp_server.py test: const 2026-01-19 12:03:26 +09:00
test_aresponses_api_with_mcp.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_mcp_auth_header_extraction.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_mcp_auth_priority.py feat(mcp): graft v2 resolver onto _create_mcp_client (none + api_key static family) (#31058) 2026-06-24 14:53:33 -07:00
test_mcp_chat_completions.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_mcp_client_unit.py fix(mcp): follow tools/list pagination from upstream servers (#39172) 2026-09-01 14:34:14 -07:00
test_mcp_guardrails.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_mcp_hooks.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_mcp_litellm_client.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_mcp_logging.py test(mcp): drain the logging worker after each test so queued callbacks cannot leak into the next test (#38228) 2026-08-25 10:50:35 -07:00
test_mcp_server.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00
test_oauth2_mcp_config.yaml [UI] M2M OAuth2 UI Flow (#20794) 2026-02-09 19:28:02 -08:00
test_openapi_spec_path_url.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_per_user_oauth_cache.py [internal copy of #28008] Support MCP OAuth passthrough and issuer-scoped JWT auth (#28356) 2026-06-02 12:22:04 -07:00
test_proxy_mcp_e2e.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_semantic_tool_filter_e2e.py test: drop the cwd-relative sys.path.insert calls from the test suite (#37802) 2026-08-22 09:25:58 -07:00