fix(mcp): set LITELLM_MASTER_KEY env var in e2e tests - #22413
Merged
Conversation
…span reset The FastAPI lifespan event (proxy_startup_event) re-reads master_key from the LITELLM_MASTER_KEY env var, overriding whatever initialize() set from the YAML config. Without this env var, master_key becomes None, causing all users to be treated as INTERNAL_USER with no MCP server access — resulting in "User not allowed to call this tool" errors. Closes #22330 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile SummaryFixes MCP e2e test failures by setting the
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| tests/mcp_tests/test_proxy_mcp_e2e.py | Adds LITELLM_MASTER_KEY env var to the session-scoped fixture to prevent proxy_startup_event from resetting the master key to None. Value is consistent with YAML config and auth header constant. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Test Fixture: _clear_proxy_database_env] --> B[Set LITELLM env var]
B --> C[initialize from YAML config]
C --> D[uvicorn.Server.serve triggers lifespan]
D --> E[proxy_startup_event reads env var]
E --> F{Env var set?}
F -->|Yes - After Fix| G[Auth credentials preserved]
F -->|No - Before Fix| H[Auth credentials reset to None]
G --> I[MCP requests succeed with 200]
H --> J[All users treated as INTERNAL_USER]
J --> K[MCP access denied with 403]
Last reviewed commit: 456ad50
Contributor
Author
CI Failure Analysis:
|
fzowl
pushed a commit
to fzowl/litellm
that referenced
this pull request
Jun 24, 2026
…agation fix(mcp): set LITELLM_MASTER_KEY env var in e2e tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
proxy_startup_event) re-readsmaster_keyfrom theLITELLM_MASTER_KEYenv var, overriding whateverinitialize()set from the YAML config. Without this env var set,master_keybecomesNone, causing all users to be treated asINTERNAL_USERwith no MCP server access.LITELLM_MASTER_KEY=sk-1234in the session-scoped test fixture so the lifespan event preserves the master key.Root Cause Analysis
_initialize_proxy()callsinitialize(config=config_path)which setsmaster_key = "sk-1234"from the YAML configuvicorn.Server.serve()triggers the FastAPI lifespan handlerproxy_startup_eventproxy_startup_eventat line 768 doesmaster_key = get_secret_str("LITELLM_MASTER_KEY")— since the env var isn't set, this returnsNone, wiping out the previously configured master keymaster_key is None→ auth returnsuser_role=INTERNAL_USER→get_allowed_mcp_servers()returns[]→ 403 errorTest plan
pytest tests/mcp_tests/test_proxy_mcp_e2e.py)Closes #22330
🤖 Generated with Claude Code