Surface photovoltage SPV spectroscopy is a common method for optoelectronic semiconductor characterization. Kelvin probe force microscopy has developed into a widely used tool for nanoscale characterization of semiconductors, metals and insulators. We present here a setup for the measurement of local surface photovoltage spectra in a Kelvin probe force microscope operated under ultrahigh vacuum conditions. The atomic force microscope tip can be placed to any desired position with nm precision and the SPV can then be recorded as a function of the wavelength of the illuminating light. We introduce the realization of the setup and present SPV spectra on two test systems, an epitaxially grown GaAs CuGaSe2 junction and a Zn doped CuInS2 polycr...