(Anglais) Metasurfaces are subwavelength spatial variations in geometry and material where the structures are of negligible thickness compared to the wavelength of light and are optimized for far-field applications, such as controlling the wavefronts of electromagnetic waves. Here, we investigate the potential of the metasurface near-field profile, generated by an incident few-cycle pulse laser, to facilitate the generation of high-frequency light from free electrons. In particular, the metasurface near-field contains higher-order spatial harmonics that can be leveraged to generate multiple higher-harmonic X-ray frequency peaks. We show that the X-ray spectral profile can be arbitrarily shaped by controlling the metasurface geometry, the electron energy, and the incidence angle of the laser input. Using ab initio simulations, we predict bright and monoenergetic X-rays, achieving energies of 30 keV (with harmonics spaced by 3 keV) from 5-MeV electrons using 3.4-eV plasmon polaritons on a metasurface with a period of 85 nm. As an example, we present the design of a four-color X-ray source, a potential candidate for tabletop multicolor hard X-ray spectroscopy. Our developments could help pave the way for compact multi-harmonic sources of high-energy photons, which have potential applications in industry, medicine, and the fundamental sciences.