litellm/tests/test_litellm/responses/mcp
Cursor Agent 2a1983aa37 fix(mcp): forward x-mcp-auth headers during MCP tool list retrieval
Previously, _get_mcp_tools_from_manager() hardcoded mcp_auth_header=None
and mcp_server_auth_headers=None when calling _get_tools_from_mcp_servers().
This meant that x-mcp-auth and x-mcp-<server>-* headers from the HTTP
request were never forwarded during tool list fetching, causing MCP servers
that require authentication to fail with 424 (Failed Dependency).

The auth headers were already correctly forwarded for tool execution
(call_tool) but were missing from the tool discovery path.

Changes:
- _get_mcp_tools_from_manager: Accept and forward mcp_auth_header,
  mcp_server_auth_headers, oauth2_headers, raw_headers parameters
- _process_mcp_tools_without_openai_transform: Thread auth headers
  through to _get_mcp_tools_from_manager
- _process_mcp_tools_to_openai_format: Thread auth headers through
- aresponses_api_with_mcp (responses/main.py): Extract MCP auth headers
  from secret_fields BEFORE tool list retrieval, not just for auto-execute
- acompletion_with_mcp (chat_completions_handler.py): Same fix - extract
  headers early and pass to tool processing

Tests:
- test_get_mcp_tools_from_manager_forwards_auth_headers
- test_process_mcp_tools_without_openai_transform_forwards_auth_headers

Co-authored-by: Ishaan Jaff <ishaan-jaff@users.noreply.github.com>
2026-02-28 03:30:16 +00:00
..
test_chat_completions_handler.py fix: replace silent if-hasattr guards with unconditional assertions in MCP streaming tests 2026-02-17 21:42:31 -03:00
test_litellm_proxy_mcp_handler.py fix(mcp): forward x-mcp-auth headers during MCP tool list retrieval 2026-02-28 03:30:16 +00:00