We present a novel method to retrieve the chemical structure of galaxies using integral field spectroscopy data through the stellar Metallicity Distribution Function (MDF). This is the probability distribution of observing stellar populations having a metallicity $Z$. We apply this method to a set of $550$ galaxies from the CALIFA survey. We present the behaviour of the MDF as a function of the morphology, the stellar mass and the radial distance. We use the stellar metallicity radial profiles retrieved as the first moment of the MDF, as an internal test for our method. The gradients in these radial profiles are consistent with the known trends: they are negative in massive early-type galaxies and tend to positive values in less massive late-type ones. We find that these radial profiles may not convey the complex chemical structure of some galaxy types. Overall, low mass galaxies ($log{M_star/mathrm{M}_{odot}}leq10$) have broad MDFs ($sigma_Zsim1.0,$dex), with unclear dependence on their morphology. However this result is likely affected by under-represented bins in our sample. On the other hand, massive galaxies ($log{M_star/mathrm{M}_{odot}}geq11$) have systematically narrower MDFs ($sigma_Zleq0.2,$dex). We find a clear trend whereby the MDFs at $r_k/R_e>1.5$ have large variance. This result is consistent with sparse SFHs in medium/low stellar density regions. We further find there are multi-modal MDFs in the outskirts ($sim18,$per cent) and the central regions ($sim40,$per cent) of galaxies. This behaviour is linked to a fast chemical enrichment during early stages of the SFH, along with the posterior formation of a metal-poor stellar population.