Magnetic anisotropy allows magnets to maintain their direction of magnetization over time. Using a scanning tunneling microscope to observe spin excitations, we determined the orientation and strength of the anisotropies of individual iron and manganese atoms on a thin layer of copper nitride. The relative intensities of the inelastic tunneling processes are consistent with dipolar interactions, as seen for inelastic neutron scattering. First-principles calculations indicate that the magnetic atoms become incorporated into a polar covalent surface molecular network in the copper nitride. These structures, which provide atom-by-atom accessibility via local probes, have the potential for engineering anisotropies large enough to produce stable magnetization at low temperatures for a single atomic spin.