We have used molecular simulations to analyze the effect of water on the adsorption of carbon monoxide in metal-organic frameworks. We have developed a model for carbon monoxide that not only reproduces the required experimental properties more accurately than previous models, but also takes into account the effect of the dipole moment on the interaction of the molecule with water and with the metal-organic framework. Our simulations were performed for Cu-BTC and IRMOF-1 with different contents of water, up to the highest water loading that each metal-organic framework can contain without losing stability. To carry out this study, we computed the entropies and energies of adsorption, the Henry coefficients, the adsorption isotherms in the dry and hydrated structures, and the molecular distributions of carbon monoxide based on the topology of the framework and on the interactions with the molecules of water. Our results show that the adsorption of carbon monoxide can be increased or decreased by controlling the amount of water in the structures.