def METHOD_NAME(cls) -> "ConnectParams | None":
    if not (port := os.getenv("DAGGER_SESSION_PORT")):
        return None
    if not (token := os.getenv("DAGGER_SESSION_TOKEN")):
        msg = "DAGGER_SESSION_TOKEN must be set when using DAGGER_SESSION_PORT"
        raise ClientConnectionError(msg)
    try:
        return cls(port=int(port), session_token=token)
    except ValueError as e:
        # only port is validated
        msg = f"Invalid DAGGER_SESSION_PORT: {port}"
        raise ClientConnectionError(msg) from e