Taking advantage of nuclear spins for electronic structure analysis, magnetic resonance imaging, and quantum devices hinges on knowledge and control of the surrounding atomic-scale environment. We measured and manipulated the hyperfine interaction of individual iron and titanium atoms placed on a magnesium oxide surface by using spin-polarized scanning tunneling microscopy in combination with single-atom electron spin resonance. Using atom manipulation to move single atoms, we found that the hyperfine interaction strongly depended on the binding configuration of the atom. We could extract atom- and position-dependent information about the electronic ground state, the state mixing with neighboring atoms, and properties of the nuclear spin. Thus, the hyperfine spectrum becomes a powerful probe of the chemical environment of individual atoms and nanostructures.