We describe a continuum model of gas uptake for inhomogeneous fluids (CMGIF) and use it to predict fluid adsorption in porous materials directly from gas-substrate interaction energies determined by first-principles calculations or accurate effective force fields. The method uses a perturbation approach to correct bulk fluid interactions for local inhomogeneities caused by gas–substrate interactions, and predicts local pressure and density of the adsorbed gas. The accuracy and limitations of the model are tested by comparison with the results of grand canonical Monte Carlo simulations of hydrogen uptake in metal–organic frameworks (MOFs). We show that the approach provides accurate predictions at room temperature and at low temperatures for less strongly interacting materials. The speed of the CMGIF method makes it a promising candidate for high-throughput materials discovery in connection with existing databases of nanoporous materials.