We present results of theoretical studies of transition metal dopants in GaAs, based on microscopic tight-binding model and ab-initio calculations. We focus in particular on how the vicinity of surface affects the properties of the hole-acceptor state, its magnetic anisotropy and its magnetic coupling to the magnetic dopant. In agreement with STM experiments, Mn substitutional dopants on the (110) GaAs surface give rise to a deep acceptor state, whose wavefunction is localized around the Mn center. We discuss a refinement of the theory that introduces explicitly the d-levels for the TM dopant. The explicit inclusion of d-levels is particularly important for addressing recent STM experiments on substitutional Fe in GaAs. In the second part of the paper we discuss an analogous investigation of single dopants in Bi2Se3 three-dimensional topological insulators, focusing in particular on how substitutional impurities positioned on the surface affect the electronic structure in the gap. We present explicit results for BiSe antisite defects and compare with STM experiments.