Theory of spin-polarized scanning tunneling microscopy applied to local spins