In this talk I will give an overview of our recent results on the investigation of the magnetism of isolated atoms and small clusters by x-ray magnetic circular dichroism, scanning tunneling microscopy and density functional theory, with a particular focus on the magnetic exchange coupling mediated by a graphene layer or by the surface of a three-dimensional topological insulator. In order to access the potential of graphene in spintronic devices, its ability to mediate magnetic exchange interactions has to be verified. I will present the results of our investigations of the magnetic coupling between 3d and 4f atoms and Ni(111) mediated by epitaxial graphene. We observe sizeable magnetic coupling for isolated adatoms of V, Fe, Co and Dy. In the case of Co, experimental data and theoretical calculations reveal that individual Co atoms occupy two distinct adsorption sites of the graphene lattice, with different magnetic coupling to the underlying Ni(111) surface . Moreover, a transition from an antiferromagnetic to a ferromagnetic coupling with increasing Co coverage is observed. These results highlight the extreme sensitivity of the exchange interaction mediated by graphene to the adsorption site and to the in-plane coordination of the magnetic atoms. Three-dimensional topological insulators have conducting surface states in the bulk band gap, protected by time-reversal symmetry, which locks spin with momentum. It was shown, however, that surface magnetic doping can break time-reversal symmetry and induces backscattering of Dirac states . I will present the results of our investigations of the magnetic properties of individual atoms of 3d transition metals (Mn, Fe, Co) deposited on the surface of the topological insulator Bi2Te3. All studied adatoms present an out-of-plane magnetic anisotropy associated with sizeable orbital moments. We find evidence of surface-mediated magnetic exchange interactions for both Mn and Co . The combination of x-ray magnetic circular dichroism and ab initio calculations reveals that the sign of the magnetic coupling at short adatom–adatom distances is opposite for Mn with respect to Co. For both elements, the magnetic exchange reverses its sign at a critical distance between magnetic adatoms, as a result of the interplay between superexchange, double exchange and Ruderman–Kittel–Kasuya–Yoshida interactions.