- simple_repro.py: Minimal script to demonstrate the bug
- force_repro_mcp_bug.py: More comprehensive reproduction
- stress_test_mcp.py: Stress test for intermittent issues
To reproduce the bug:
git checkout HEAD~2 -- litellm/responses/mcp/litellm_proxy_mcp_handler.py
python simple_repro.py
To see the fix working:
git checkout HEAD -- litellm/responses/mcp/litellm_proxy_mcp_handler.py
python simple_repro.py
Co-authored-by: ishaan <ishaan@berri.ai>
Added repro_mcp_bug.py which:
- Demonstrates the NoneType error that occurred with back-to-back MCP calls
- Tests None handling in MCP handler functions directly
- Can run with mocks (--mock) or against a real LiteLLM proxy
- Verifies the defensive None checks are working correctly
Usage:
python repro_mcp_bug.py --direct # Test None handling directly
python repro_mcp_bug.py --mock # Test with mocks
python repro_mcp_bug.py # Full test (requires API key for real API test)
Co-authored-by: ishaan <ishaan@berri.ai>
Fixed the 'argument of type NoneType is not iterable' error that occurred when
making back-to-back MCP Responses API calls. The issue was caused by missing
defensive checks for None values in several places:
1. _get_allowed_mcp_servers_from_mcp_server_names: Added None check for
allowed_mcp_servers parameter before iteration
2. _get_mcp_tools_from_manager: Added defensive checks to ensure
allowed_mcp_server_ids and allowed_mcp_servers are always lists
3. _deduplicate_mcp_tools: Added None checks for both mcp_tools and
allowed_mcp_servers parameters
4. _filter_mcp_tools_by_allowed_tools: Added None checks for both
mcp_tools and mcp_tools_with_litellm_proxy parameters
5. _extract_mcp_headers_from_params in streaming iterator: Added
try-catch and hasattr check to safely iterate over tools
6. _create_initial_response_iterator: Improved error handling and
added validation for tools parameter
Added test test_mcp_handler_none_defensive_checks to verify the fix.
Co-authored-by: ishaan <ishaan@berri.ai>
* Fix: SSO user roles are not updated for existing users
Fixes#19620
* Refactor: Remove redundant user_info retrieval in SSOAuthenticationHandler
* Test: add new tests for user creation and updates in get_user_info_from_db