Magnesium is an abundant metal element in space, and magnesium chemistry has vital importance in the evolution of interstellar medium (ISM) and circumstellar regions, such as the asymptotic giant branch star IRC+10216 where a variety of Mg compounds bearing H, C, N, and O have been detected and proposed as the important components in the gas-phase molecular clouds and solid-state dust grains. Herein, we report the formation and infrared spectroscopic characterization of the Mg-bearing molecules HMg, [Mg, N, C], [Mg, H, N, C], [Mg, N, C, O], and [Mg, H, N, C, O] from the reactions of Mg/Mg + and the prebiotic isocyanic acid (HNCO) in the solid neon matrix. Based on their thermal diffusion and photochemical behavior, a complex reactivity landscape involving association, decomposition, and isomerization reactions of these Mg-bearing molecules is developed, which can not only help understand the chemical processes of the magnesium (iso)cyanides in astrochemistry but also provide implications on the presence of magnesium (iso)cyanates in the ISM and the chemical model for the dust grain surface reactions. It also provides a new paradigm of the key intermediate nature of the cationic complexes in the formation of neutral interstellar species.