A simple algorithm is presented to derive accurately the exchange-correlation potential in the density functional theory (DFT) from the electron density. The method, which can be used with any physically acceptable density as input, is applied here to the densities in atoms obtained from high-level Green’s function calculations. The resulting potentials show the correct asymptotic behavior and the characteristic intershell peaks. We illustrate the possible use of these potentials in fitting procedures for new functionals, by investigating the HCTH functional [F. A. Hamprecht, A. J. Cohen, D. J. Tozer, and N. C. Handy, J. Chem. Phys. 109, 6264 (1998)]. The potentials derived from Green’s function one-body densities provide a microscopic foundation for present-day functionals in DFT, and may therefore be helpful in the ultimate goal of constructing functionals on a fully ab initio basis.