We examine the relation between gas-phase oxygen abundance and stellar mass---the MZ relation---as a function of the large scale galaxy environment parameterized by the local density. The dependence of the MZ relation on the environment is small. The metallicity where the MZ relation saturates and the slope of the MZ relation are both independent of the local density. The impact of the large scale environment is completely parameterized by the anti-correlation between local density and the turnover stellar mass where the MZ relation begins to saturate. Analytical modeling suggests that the anti-correlation between the local density and turnover stellar mass is a consequence of a variation in the gas content of star-forming galaxies. Across $sim1$ order of magnitude in local density, the gas content at a fixed stellar mass varies by $sim5%$. Variation of the specific star formation rate with environment is consistent with this interpretation. At a fixed stellar mass, galaxies in low density environments have lower metallicities because they are slightly more gas-rich than galaxies in high density environments. Modeling the shape of the mass-metallicity relation thus provides an indirect means to probe subtle variations in the gas content of star-forming galaxies.