We propose an efficient method to explore the configuration space of nanoclusters by combining together ab initio molecular dynamics, metadynamics and data clustering algorithms. On one side, we employ collective variables sensitive to topological changes in the network of interatomic connections to map the configuration space; on the other, we introduce an automatic approach to select, in such space, representative structures to be optimized. In this way, we show that it is possible to sample thoroughly the set of relevant nanocluster geometries, at a limited computational cost. We apply our method to explore MoS 2 clusters, that recently raised a sizable interest due to their remarkable electronic and catalytic properties. We demonstrate that the unsupervised algorithm is able to find a large number of low-energy structures at different cluster sizes, including both bulk-like geometries and very different topologies. We are thus able to recapitulate, in a single computational study on technologically-relevant MoS 2 clusters, the results of all previous works that employed distinct techniques like genetic algorithms or heuristic hypotheses. Furthermore, we found several new structures not previously reported. The ensemble of MoS 2 cluster structures is deposited in a publicly accessible database.