litellm/tests/mcp_tests
Thibault Serot b6d9d85f3e fix(responses): reject MCP gateway requests that resolve zero tools
A request that explicitly asks for MCP tools via server_url litellm_proxy/...
but resolves none of them (the API key/team has no access to the MCP server
via allow_all_keys=false and no object-permission grant, the server name does
not exist, or allowed_tools matches nothing) was silently sent to the model
with no tools. The model then hallucinates, and the only trace is a
list_mcp_tools spend log with status success and an empty response — the
request looks healthy end to end while being completely broken.

Raise a 400 BadRequestError naming the requested server URLs and the likely
causes instead. Guard scope:

- Mixed requests are exempt: with other (function) tools present, the request
  proceeds using those tools, matching the previous fallback behaviour.
- Opt-out via litellm.reject_empty_mcp_resolved_tools = False (default True,
  per maintainer guidance).

The auth-header pass-through test in tests/mcp_tests now resolves a dummy
tool, since its purpose is header propagation, not zero-tool behaviour.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-09 14:55:58 +10:00
..
test_configs [Release Fix] (#22411) 2026-02-28 09:46:35 -08:00
conftest.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
mcp_server.py test: const 2026-01-19 12:03:26 +09:00
test_aresponses_api_with_mcp.py fix(responses): reject MCP gateway requests that resolve zero tools 2026-07-09 14:55:58 +10: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 style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_mcp_guardrails.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -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 style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_mcp_logging.py style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00
test_mcp_server.py chore: litellm oss staging 250626 (#31305) 2026-06-25 21:00:28 -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 style: run black formatter on files from main merge 2026-04-17 13:02:59 -07:00