I am sorry that you have been kept out of the life of your daughter for so long.
The process for trying to be legally declared her father is a complaint to establish paternity, under chapter 209C, section 3 of the Massachusetts General Laws. I have linked it below.
Unfortunately, you may have a very uphill battle asserting your parentage because Massachusetts law prefers to establish permanency for children with their legal and psychological parent over acknowledging the parenthood of a birth father who is late to the relationship.
I have linked below, the Mass. statute that makes the voluntary acknowledgment of paternity, which the mother and her ex-boyfriend must have signed to put him on the birth certificate, permanent and legally unassailable after 1 year. (Mass. Gen. Laws. chapter 209C, section 11.) I have also linked the Mass. Trial Court Law Libraries' research page "Mass. Law About Paternity".
About the only chance you would have would be if the man who has custody of your daughter is willing to support your petition to have your actual parentage adjudicated. Even then, the court does not have to allow your petition and
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.
I would say that this is the kind of circumstance where you need to hire an attorney. If two lawyers can fight about it, if either the mother, or the legal father tries to stop you - you will probably lose if you are pro se (unrepresented by a lawyer).
The above advice is friendly advice, and not legal advice. You should not rely on anyone's advice, unless you are paying for it.
I agree with the prior responses. You may want to find out from the mother of the child if the mother will agree to a paternity test first. This could save you a lot of time and expense if you are not the biological parent of the child. You should consult with a qualified family law attorney to assess your options and to implement a good strategy based on the facts in your case.
Advice provided is of a general nature to provide guidance. Divorce law is state specific. One should always check the laws in their home jurisdiction. An attorney-client relationship is not intended or established through provided responses.
Sign up to receive a 3-part series of useful information and advice about child custody law.