We have used the Whole Atmosphere Community Climate Model (WACCM) to calculate the distribution of CO2 and CO in the mesosphere and lower thermosphere (MLT), and we have compared the results with observations, mainly from the Atmospheric Chemistry Experiment Fourier Transform Spectrometer and Michelson Interferometer for Passive Atmospheric Sounding satellite-borne instruments. We find that WACCM can reproduce the observed distribution of CO2 in the MLT and the rapid falloff of CO2 above about 80 km. Analysis of the principal terms in the calculated budget of CO2 shows that its global-mean vertical profile is determined mainly by the competition between molecular diffusive separation and eddy mixing by gravity waves. The model underestimates somewhat the mixing ratio of CO2 in the thermosphere compared to that in the observations, but we show that the discrepancy may be eliminated by a reasonable adjustment of the Prandtl number used to calculate the diffusivity due to gravity waves. Simulated CO is also consistent with observations, except that in the standard version of the model, its mixing ratio is uniformly lower than observed above about 100 km. We conclude that WACCM likely underestimates the rate of production of CO in the lower thermosphere from photolysis of CO2 at wavelengths < 121 nm, and we show that this stems from the use of a very large absorption cross section for O2 in the wavelength range 105–121 nm. When a smaller cross section is used, photolysis of CO2 increases by a factor of 2–3 at ~ 95–115 km and, as a result, CO mixing ratios become larger and agree much more closely with observations. We emphasize that the increase in CO2 photolysis implies only minor changes in the vertical profile of CO2 because photolytic loss is a minor term in the budget of CO2 in the MLT.