  Engineering the local density of states with nanophotonic structures is a
powerful tool to control light-matter interactions via the Purcell effect. At
optical frequencies, control over the electric field density of states is
typically used to couple to and manipulate electric dipole transitions.
However, it is also possible to engineer the magnetic density of states to
control magnetic dipole transitions. In this work, we experimentally
demonstrate the optical magnetic Purcell effect using a single rare earth ion
coupled to a nanophotonic cavity. We engineer a new single photon emitter,
Er$^{3+}$ in MgO, where the electric dipole decay rate is strongly suppressed
by the cubic site symmetry, giving rise to a nearly pure magnetic dipole
optical transition. This allows the unambiguous determination of a magnetic
Purcell factor $P_m=1040 \pm 30$. We further extend this technique to realize a
magnetic dipole spin-photon interface, performing optical spin initialization
and readout of a single Er$^{3+}$ electron spin. This work demonstrates the
fundamental equivalence of electric and magnetic density of states engineering,
and provides a new tool for controlling light-matter interactions for a broader
class of emitters.
