BerriAI/litellm · error · HTTPException

MCP upstream token endpoint returned no response

Error message

MCP upstream token endpoint returned no response

What it means

The POST to the upstream OAuth token endpoint completed without an HTTP response object (connection-level failure or an httpx client returning None). The gateway converts this absent-response case into a 502 instead of crashing on a None dereference downstream.

Source

Thrown at litellm/proxy/_experimental/mcp_server/discoverable_endpoints.py:1033

            log_context=mcp_server.server_id,
        )
        upstream_rejected_bridge_refresh: Final = (
            is_bridge
            and grant_type == "refresh_token"
            and isinstance(fault, CallerRejected)
            and fault.code == "invalid_grant"
        )
        if upstream_rejected_bridge_refresh:
            verbose_logger.info(
                "bridge refresh: the upstream rejected the sealed refresh token for server=%s with "
                "invalid_grant (revoked or expired at the IdP); returning invalid_grant so the client "
                "re-runs authorization_code rather than an opaque upstream error",
                mcp_server.server_id,
            )
            return _bridge_mint_error_response("invalid_refresh")
        return render_token_fault(fault)
    if response is None:
        raise HTTPException(
            status_code=502,
            detail="MCP upstream token endpoint returned no response",
        )
    token_response = response.json()

    # Validate token response against server-configured rules before any storage.
    # This rejects tokens from wrong Slack workspaces, Atlassian orgs, etc.
    if mcp_server.token_validation and isinstance(mcp_server.token_validation, dict):
        _validate_token_response(
            token_response=token_response,
            validation_rules=mcp_server.token_validation,
            server_id=mcp_server.server_id,
        )

    # Store server-side when the server is configured for per-user OAuth and
    # the calling client has provided a valid LiteLLM identity.
    # Errors are non-fatal: the token is still returned to the client.
    if mcp_server.needs_user_oauth_token:

View on GitHub (pinned to 77b7c6c40c)

Solutions

  1. Check network connectivity to the upstream token endpoint.
  2. Verify the token URL is correct and the upstream server is up.

Example fix

curl the token endpoint directly to confirm reachability.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at litellm/proxy/_experimental/mcp_server/discoverable_endpoints.py:1033 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/87e9748825078917. Report an issue: GitHub.