In this contribution I will review the current status of cosmological constraints based on the determination of the mass function of galaxy groups and clusters, and its redshift evolution. After describing the approaches to calibrate all analytical expression for the cosmological mass function of collapsed dark matter halos, I will discuss the methods, based on X-ray observations, to compute cluster masses. I will then critically discuss the constraints on cosmological parameters, which have been derived so far, and the future perspectives from upcoming surveys from Sunyaev-Zeldovich and X-ray observations.