I would make it a semi-controlled substance. Procuring some would require a doctor's prescription, however the doctor's role would only be to make sure the person is physically and mentally suitable for taking it. They would have to verify age (16+), allergy concerns, dosage by body weight and type, that the subject wants to try it for the right reasons (mind-expansion, increased empathy, etc., and not 'cos their friends did it) and that the subject understands the effects- both negative and positive- and how to take care of themselves under the influence. If all these tests are passed (retested every six months), the subject is prescribed one dose a month.
Obviously there would still be an underground market for MDMA (just like perks or T3s), for the people who do it more than once a month, however the market would be flooded with clean pills, lowering the risk factor. Buying or selling non-prescribed pills would still be illegal. Also, everyone who has ever been prescribed MDMA would have their stats listed in a database, including their dosage by body weight and type, and if caught with more than that on them, could be charged with Intent to Traffic.