BerriAI/litellm · error · ValueError
OAuth2 token response for MCP server '{server.server_id}' mi
Error message
OAuth2 token response for MCP server '{server.server_id}' missing 'access_token' What it means
Raised when the MCP server's OAuth2 token endpoint returns 2xx with a JSON object body, but that object lacks the mandatory 'access_token' key required by RFC 6749. The request itself succeeded — this is a shape validation on the response, distinct from the HTTP-status failure handled just above — and typically means the token_url points at the wrong endpoint or the server issues malformed tokens.
Source
Thrown at litellm/proxy/_experimental/mcp_server/oauth2_token_cache.py:167
response: Final = await client.post(server.token_url, data=data, headers=token_request.headers or None)
response.raise_for_status()
except httpx.HTTPStatusError as exc:
raise ValueError(
f"OAuth2 token request for MCP server '{server.server_id}' "
f"failed with status {exc.response.status_code}"
) from exc
body: Final = response.json()
if not isinstance(body, dict):
raise ValueError(
f"OAuth2 token response for MCP server '{server.server_id}' "
f"returned non-object JSON (got {type(body).__name__})"
)
access_token: Final = body.get("access_token")
if not access_token:
raise ValueError(f"OAuth2 token response for MCP server '{server.server_id}' missing 'access_token'")
# Safely parse expires_in — providers may return null or non-numeric values
raw_expires_in: Final = body.get("expires_in")
try:
expires_in = int(raw_expires_in) if raw_expires_in is not None else MCP_OAUTH2_TOKEN_CACHE_DEFAULT_TTL
except (TypeError, ValueError):
expires_in = MCP_OAUTH2_TOKEN_CACHE_DEFAULT_TTL
ttl: Final = max(
expires_in - MCP_OAUTH2_TOKEN_EXPIRY_BUFFER_SECONDS,
MCP_OAUTH2_TOKEN_CACHE_MIN_TTL,
)
verbose_logger.info(
"Fetched OAuth2 token for MCP server %s (expires in %ds)",
server.server_id,
expires_in,
)View on GitHub (pinned to 77b7c6c40c)
Solutions
- Check the upstream token response contains access_token; verify grant and credentials.
Example fix
Log the token response and confirm 'access_token' is present.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/proxy/_experimental/mcp_server/oauth2_token_cache.py:167 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/08475d5e099cee90.
Report an issue: GitHub.