I can imagine how tough it is for you, SJWRSW. What you describe of your step daughter's behaviour is at the extreme end of normal for her age. You both worry but her father is the parent in this situation, he needs to lay down the law a bit. However it isn't an easy time.
From what you say, you and your husband are doing your best. I wonder why he was not allowed to see the children for so long - I 'get' that the place he rented wasn't quite the thing for them to stay but surely he could have still seen them either at their home or take them out.
Early on in your opening post you describe her mother as a 'fruitcake' and you having a 'mental breakdown' tonight. I don't know about her mother but nobody has a mental breakdown in one evening, there's a gradual build up. I wonder if the mother had reached the end of her tether with her daughter which is why she moved in with you, I hope she sees her mother though.
You may well end up with some mental health problems if you continue in this unhappy situation. You're very young to be coparenting a seventeen year old with a small one of your own.
Honestly I will never understand women who marry men with dependent children, it seems like one big headache to me but what's done is done.
I'm assuming the girl knows all about STIs and contraception even if she does tell you she takes risks - could be just saying that to wind you up. What she wears is not your business but you have a right to insist she brings no drugs home. MDMA is Ecstasy and it is illegal here in the UK however a lot of young people take it and most are OK, they need to keep up their fluid levels because dehydration causes problems - even death, rarely. I expect SD knows more about that than any of us.
Up to you what you do but make sure you have an escape route and the exits are clear.
Good luck.