Such a commonly available intervention, I'm a bit skeptical that this works.
In my own first-person experience, magnesium supplementation has had no discernable effect on Cocaine Use Disorder.
N-acetylcysteine (NAC), on the other hand, has had a minor but noticeable ability to mitigate cravings.[1]