BerriAI/litellm · error · ValueError
MCP server '{server.server_id}' missing required OAuth2 fiel
Error message
MCP server '{server.server_id}' missing required OAuth2 fields: client_id={bool(server.client_id)}, client_secret={bool(server.client_secret)}, token_url={bool(server.token_url)} What it means
Error "MCP server '{server.server_id}' missing required OAuth2 fields: client_id={bool(server.client_id)}, client_secret={bool(server.client_secret)}, token_url={bool(server.token_url)}" thrown in BerriAI/litellm.
Source
Thrown at litellm/proxy/_experimental/mcp_server/oauth2_token_cache.py:123
async with self._get_lock(identity):
cached = self.get_cache(identity)
if cached is not None:
return cached
token, ttl = await self._fetch_token(server)
self.set_cache(identity, token, ttl=ttl)
return token
async def _fetch_token(self, server: "MCPServer") -> tuple[str, int]:
"""POST to ``token_url`` with ``grant_type=client_credentials``.
Returns ``(access_token, ttl_seconds)`` where ttl accounts for the
expiry buffer so the cache entry expires before the real token does.
"""
client: Final = get_async_httpx_client(llm_provider=httpxSpecialProvider.MCP)
if not server.client_id or not server.client_secret or not server.token_url:
raise ValueError(
f"MCP server '{server.server_id}' missing required OAuth2 fields: "
f"client_id={bool(server.client_id)}, "
f"client_secret={bool(server.client_secret)}, "
f"token_url={bool(server.token_url)}"
)
token_request: Final = build_upstream_oauth2_token_request(
server,
auth_method=server.token_endpoint_auth_method,
client_id=server.client_id,
client_secret=server.client_secret,
)
data: Final[dict[str, str]] = {
"grant_type": "client_credentials",
**token_request.body,
}
if server.scopes:
data["scope"] = " ".join(server.scopes)View on GitHub (pinned to 77b7c6c40c)
Solutions
- Set client_id, client_secret, and token_url on the MCP server config.
Example fix
Configure all three OAuth2 fields for the server.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at litellm/proxy/_experimental/mcp_server/oauth2_token_cache.py:123 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/52053b3d186dba15.
Report an issue: GitHub.