BerriAI/litellm · error · HTTPException
Error caching temporary mcp server: {e}
Error message
Error caching temporary mcp server: {e} What it means
Returned (500) when the temporary-server setup block fails: either _persist_draft_mcp_server (DB write of the draft row) or _cache_temporary_mcp_server_in_redis (Redis write with TEMPORARY_MCP_SERVER_TTL_SECONDS). The original exception is logged via verbose_proxy_logger.exception, then surfaced as this generic 500; nothing usable is returned to the caller.
Source
Thrown at litellm/proxy/management_endpoints/mcp_management_endpoints.py:1670
temp_record,
credentials_are_encrypted=False,
)
_cache_temporary_mcp_server(
temporary_server,
ttl_seconds=TEMPORARY_MCP_SERVER_TTL_SECONDS,
)
await _persist_draft_mcp_server(
payload_with_credentials,
temp_record.server_id,
created_by,
)
await _cache_temporary_mcp_server_in_redis(
temporary_server,
ttl_seconds=TEMPORARY_MCP_SERVER_TTL_SECONDS,
)
except Exception as e:
verbose_proxy_logger.exception("Error caching temporary mcp server: %s", e)
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail={"error": f"Error caching temporary mcp server: {e}"},
)
return _redact_mcp_credentials(temp_record)
async def _mcp_oauth_user_api_key_auth(request: Request) -> UserAPIKeyAuth:
"""
Auth dependency for MCP OAuth browser-navigation endpoints (/authorize, /token).
Tries the Authorization header first. Falls back to decoding the UI
'token' session cookie (set by SSO login) to extract the API key, which
allows browser-based OAuth redirects to work without an explicit
Authorization header.
"""
import jwt as _jwt
from litellm.proxy.proxy_server import master_keyView on GitHub (pinned to 77b7c6c40c)
Solutions
- Check the proxy logs for the wrapped exception's traceback to see which leg failed (draft persist vs Redis cache).
- Verify the proxy's Redis connection (redis_url) and that Redis is reachable.
- Verify DB connectivity/migrations if the draft persist is the failing call.
- Retry the session flow once infrastructure is healthy; temp entries are TTL-scoped so partial state ages out.
Defensive patterns
Strategy: retry
Validate before calling
try:
import redis
redis.Redis.from_url(REDIS_URL).ping()
except Exception as e:
raise RuntimeError(f"Redis unavailable; temp MCP server flow will 500: {e}") Try / catch
for attempt in range(2):
try:
return create_temp_session(payload)
except HTTPError as e:
if e.response.status_code == 500 and attempt == 0:
sleep(2)
continue # transient Redis/DB hiccup; temp entries are TTL-scoped so retry is safe
raise Prevention
- Deploy Redis and set redis_url before using OAuth session flows.
- Check proxy logs to distinguish draft-persist failure from Redis-cache failure.
- Retry only after confirming infra health; persistent 500s mean config, not flake.
When it happens
Trigger: Running the admin MCP OAuth session flow while Redis is down or redis_url is not configured on the proxy; the draft DB write failing (DB down, schema drift); values in the payload failing serialization on the way into the cache.
Common situations: Proxy deployed without the Redis instance that temporary MCP server caching requires; Redis restarted or evicting mid-flow; DB outage during OAuth setup.
Related errors
- Error fetching cache settings: {e}
- Error updating cache settings: {e}
- Error creating mcp server: {e}
- User does not have permission to create temporary mcp server
- MCP server {server_id} not found
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/c3f42aa244fe7ede.
Report an issue: GitHub.