BerriAI/litellm · error · HTTPException
Invalid or expired credential
Error message
Invalid or expired credential
What it means
HTTP 401 from MCP auth: the bridge envelope's signature/expiry check failed, or the referenced key is missing, blocked, or expired. It deliberately hides which check failed so an attacker cannot probe the envelope format.
Source
Thrown at litellm/proxy/_experimental/mcp_server/auth/user_api_key_auth_mcp.py:800
if not master_key:
raise HTTPException(status_code=500, detail="Server misconfigured: master_key is not set")
await MCPRequestHandler._run_pre_db_read_auth_checks(request=request, route=route)
keys: Final = envelope_keys_from_master_key(master_key)
result: Final = resolve_bridge_envelope(authorization_value, keys, datetime.now(timezone.utc), server.server_id)
match result:
case BridgeEnvelopeAdmitted():
header_key: Final = server.alias or server.server_name
if header_key is None:
raise HTTPException(status_code=500, detail="Server misconfigured: MCP server has no routable name")
admitted: Final = await MCPRequestHandler._reload_admitted_principal(result.identity)
await MCPRequestHandler._enforce_admitted_live_policy(admitted=admitted, request=request, route=route)
injected: Final = {header_key: {"Authorization": result.upstream_authorization.get_secret_value()}}
new_headers: Final = {**(mcp_server_auth_headers or {}), **injected}
return admitted, new_headers
case BridgeEnvelopeInvalid() | NotBridgeEnvelope():
raise HTTPException(status_code=401, detail="Invalid or expired credential")
case _:
assert_never(result)
@staticmethod
async def _admit_gateway_session(
authorization_value: str,
request: Request,
route: str,
mcp_servers: list[str] | None,
) -> UserAPIKeyAuth:
"""Open a gateway DCR session bearer and admit the live litellm user it references.
Identity-only sibling of :meth:`_admit_dcr_bridge_delegate`: the session token seals no
upstream credential (those are vaulted per user, resolved at egress), so authorization is
resolved fresh via :meth:`_reload_admitted_user` + the centralized policy gate rather than a
mint-time snapshot. Pre-DB gates (size, IP, route allowlist) run first, mirroring the standard
pipeline. Fails closed with the requested scope's ``invalid_token`` challenge on an expired,
tampered, foreign, or refresh token, or a missing/deactivated/policy-rejected user."""View on GitHub (pinned to 77b7c6c40c)
Solutions
- Re-authenticate: the credential (token/cookie) is invalid or expired.
- Check the Authorization header value.
Example fix
Obtain a fresh token and retry the request.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at litellm/proxy/_experimental/mcp_server/auth/user_api_key_auth_mcp.py:800 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18).
Data as JSON: /api/errors/00e9b55328bc1774.
Report an issue: GitHub.