VERY, VERY interesting fact pattern -- and NO disrespect to you intended at all. It is just so very complex.
You really need to hire VERY experienced legal counsel in the area of family law to assist you. I wish it were otherwise, but this is incredibly complex, and, in a more straightforward answer, NO -- you are not still "married" -- but that does not even begin to answer your very complex questons.
Best wishes to you and your family!
My very, very best wishes to you and your family! In a molre straightforward
No attorney-client relatonship is created in responding to this question, and advice provided is based solely on very limited facts presented, and therefore may not be correct. You are advised that it is always best to contact a competent and experienced with the practice of law in the county in which you reside, particularly as it relates to family law, child support, custody and visitation (a/k/a "parenting time") issues, including 209A abuse-prevention restraining orders (a/k/a "ROs" in legal-speak), regarding un-emancipated children, under the age of 22.
I am sorry that you are going through such pain with the mother of your child. I agree with Atty. Molloy that you present a complex fact pattern that should be discussed with an experienced family law attorney. Preferably a family law attorney with experience or serious interest in LGBTQ issues. I believe PFLAG and GLAD both have lawyer referral services.
I am confused about why you ask if you are still legally married. You call the child's mother your "ex wife" but do not mention having gotten a divorce. Because Massachusetts recognizes marriages between same gender as well as opposite gender couples, I do not believe that your change of gender since your marriage would affect the validity of your marriage, unless you have actually been divorced.
As far as custody of your daughter, since you were married to her mother when she was born, you would be able to obtain a judgment concerning custody, visitation and support the same as any other divorcing or divorced couple -- through either a divorce agreement, a divorce judgment, a modification agreement or a modification judgment.
The courts are not likely to terminate the mother's rights or let you adopt your own child, unless you are married to a new spouse who has a significant relationship with your daughter and would join you in a step-parent adoption petition and it was in your daughter's best interests to permanently sever her relationship with her birth mother.
The mother being unstable and admitting that your daughter needs to live with you will be helpful in getting a custody but that is not the same as her surrendering her rights such as would permit an adoption. The mother letting your daughter live with her is also not likely enough for a court to terminate her obligations to your daughter, unless there were to be a new second parent to legally incorporate into your daughter's life.
As there are very likely MANY other circumstances surrounding your family that were not and cannot be addressed in a simple post on an advice site, your best option is to gather all your paperwork and evidence and consult an attorney for a detailed review, legal research and the development of a legal plan for pursuing your daughter's best interests.
NOTE: This answer is made available by the lawyer for educational purposes only. By using or participating in this site you understand that there is no attorney client privilege between you and the attorney responding. This site should not be used as a substitute for competent legal advice from a licensed professional attorney in your area who regularly practices in the subject matter which your question is about. You should develop an attorney client relationship with the lawyer of your choice so that your communications will be subject to the attorney client privilege and have the other benefits of a professional relationship. The law changes frequently and varies from jurisdiction to jurisdiction. The information and materials provided are general in nature, and may not apply to a specific matter as partially described in the question.