Magnesium cyanide
Magnesium cyanide is a chemical compound with the formula Mg(CN)2. It is a toxic white solid. Unlike calcium isocyanide, the cyanide ligands prefer to coordinate at carbon, with a 0.3kcal/mol isomerization barrier. If heated to 500 °C, it decomposes to magnesium nitride. Preparation
The first attempt to prepare magnesium cyanide was attempted in 1924. It was attempted by reacting a solution of hydrogen cyanide in water with magnesium metal:
HCN + Mg → Mg(CN)2 + H2
However, no magnesium cyanide was observed, only magnesium hydroxide formed. To avoid this problem, instead of using water as the reaction medium, pure ammonia was used at -30 °C. This formed magnesium cyanide ammoniate, which in turn was heated to 180 °C to produce magnesium cyanide. Other methods are possible, such as the decomposition of magnesium ferricyanide in an electric carbon tube, which produces iron carbide as a byproduct. Complexes
Magnesium cyanide reacts with silver nitrate to form magnesium silver cyanide, with the formula MgAg2(CN)4. When this compound is heated it produces hydrogen cyanide gas and magnesium hydroxide in the presence of water, which meant it could not be used as a pathway for the production of magnesium cyanide. When silver nitrate reacts with magnesium cyanide, it also produces another magnesium silver cyanide, with the formula MgAg(CN)3. References

Magnesium compounds
cyanides