Involved in several important metabolic functions. It plays a role in the production and transport of energy. It is also important for the contraction and relaxation of muscles. Magnesium is involved in the synthesis of protein, and it assists in the functioning of certain enzymes in the body. Most dietary magnesium comes from vegetables, particularly dark-green, leafy vegetables. Other foods that are good sources of magnesium are soy products, such as soy flour and tofu; legumes and seeds; nuts (such as almonds and cashews); whole grains (such as brown rice and millet); and fruits or vegetables (such as bananas, dried apricots, and avocados).