Context. The stellar metallicity and its gradient place constraints on the formation and evolution of galaxies. Aims. This is a study of the metallicity gradient of the LMC, SMC and M33 galaxies derived from their asymptotic giant branch (AGB) stars. Methods. The [Fe/H] abundance was derived from the ratio between C- and M-type AGB stars and its variation analysed as a function of galactocentric distance. Galaxy structure parameters were adopted from the literature. Results. The metallicity of the LMC decreases linearly as −0.047±0.003 dex kpc−1 out to ∼8 kpc from the centre. In the SMC, [Fe/H] has a constant value of ∼−1.25 ± 0.01 dex up to ∼12 kpc. The gradient of the M33 disc, until ∼9 kpc, is −0.078 ± 0.003 dex kpc−1 while the outer disc/halo, out to ∼25 kpc, has [Fe/H] ∼ −1.7 dex. Conclusions. The metallicity of the LMC, as traced by different populations, bears the signature of two major star forming episodes: the first one constituting a thick disc/halo population and the second one a thin disc and bar due to a close encounter with the Milky Way and SMC. The [Fe/H] of the recent episode supports an LMC origin for the Stream. The metallicity of the SMC supports star formation, ∼3 Gyr ago, as triggered by LMC interaction and sustained by the bar in the outer region of the galaxy. The SMC [Fe/H] agrees with the present-day abundance in the Bridge and shows no significant gradient. The metallicity of M33 supports an “insideout” disc formation via accretion of metal poor gas from the interstellar medium.