  Using first-principles calculations, we studied Mn$_2$RuZ (Z=Al, Ga, Si, Ge)
and their heterojunctions with MgO along (001) direction. All these alloys
possess Hg$_2$CuTi-type inverse Heusler alloy structure and ferrimagnetic
ground state. Our study reveals the half-metallic electronic structure with
highly spin-polarized $\Delta_1$ band, which is robust against atomic disorder.
Next we studied the electronic structure of Mn$_2$RuAl/MgO and Mn$_2$RuGe/MgO
heterojunctions. We found that the MnAl- or MnGe-terminated interface is
energetically more favorable compared to the MnRu-terminated interface.
Interfacial states appear at the Fermi level in the minority-spin gap for the
Mn$_2$RuGe/MgO junction. We discuss the origin of these interfacial states in
terms of local environment around each constituent atom. On the other hand, in
the Mn$_2$RuAl/MgO junction, high spin polarization of bulk Mn$_2$RuAl is
preserved independent of its termination.
