Recent observations of the potentially habitable planets TRAPPIST-1 e, f, and g suggest that they possess large water mass fractions of possibly several tens of weight percent of water, even though the host star's activity should drive rapid atmospheric escape. These processes can photolyze water, generating free oxygen and possibly desiccating the planet. After the planets formed, their mantles were likely completely molten with volatiles dissolving and exsolving from the melt. To understand these planets and prepare for future observations, the magma ocean phase of these worlds must be understood. To simulate these planets, we have combined existing models of stellar evolution, atmospheric escape, tidal heating, radiogenic heating, magma-ocean cooling, planetary radiation, and water-oxygen-iron geochemistry. We present , a versatile magma-ocean evolution model, validated against the rocky super-Earth GJ 1132b and early Earth. We simulate the coupled magma-ocean atmospheric evolution of TRAPPIST-1 e, f, and g for a range of tidal and radiogenic heating rates, as well as initial water contents between 1 and 100 Earth oceans. We also reanalyze the structures of these planets and find they have water mass fractions of 0–0.23, 0.01–0.21, and 0.11–0.24 for planets e, f, and g, respectively. Our model does not make a strong prediction about the water and oxygen content of the atmosphere of TRAPPIST-1 e at the time of mantle solidification. In contrast, the model predicts that TRAPPIST-1 f and g would have a thick steam atmosphere with a small amount of oxygen at that stage. For all planets that we investigated, we find that only 3–5% of the initial water will be locked in the mantle after the magma ocean solidified.