Generally, the court will consider matters of custody by examining what is in the best interests of the child. The best interests of the child standard includes many factors. The court considers the presence of all relevant factors in its custody orders, and each factor, including those having to do with mental health issues, may be weighed differently from the others, depending on the individual facts of the case.
Three of the factors which are particularly relevant to the issue of medication are the factor of parental fitness, the factor of ability and willingness of the parent to care for the child, and the factor of health of the parent. Let’s examine each of these three factors below:
1. Parental Fitness and Medication
Unfitness of one parent might clearly disqualify that parent from obtaining custody of the children.
In one Massachusetts case, custody was awarded to the mother after she proved that she was dealing with her depression and emotional issues successfully, despite a short period of hospitalization. The father appealed, but the Appeals Court agreed with the trial judge, noting: “In our opinion, on the evidence before her, the judge could permissibly conclude; (a) that Marie is dealing successfully with her emotional problems; (b) that of the two parents “she despite her problems can offer the children more room for growth”; (c) that Gino has an “obsession with keeping control over the life of his wife and children” which causes much of her stress; and (d) that the welfare of the children will best be served by granting custody to their mother, with liberal and specific rights of visitation for the father.” 
Being on medication for mental health issues, then, might actually be a positive factor for the parent seeking custody, as long as the parent can show that the medication is helping the parent overcome mental health issues successfully, and that it does not affect his or her fitness as a parent.
There is a line of cases which does not directly deal with custody disputes but is relevant to this discussion: cases that deal with the termination of parental rights and the care and protection of children. In one recent appellate case, the mother was able to show that she was fit to care for her child, age nine, despite suffering from severe past trauma, ADHD, past substance abuse, and an executive function disorder. In that case, the child also suffered from several mental and emotional issues and was on medication for them. The Appeals Court reversed the trial judge’s order for care and protection of the child.
By contrast, two other cases in which the mental or emotional health of the parent was contested found that the parent in each case was unable to care for her child: in one, the mother neglected to attend necessary treatment; in the other, the mother refused to complete ordered substance abuse programs and had a history of visiting multiple doctors in order to obtain additional prescription drugs. 
2. Ability and Willingness of the Parent to Care for the Child and Medication
When the Probate and Family Court examines the ability and willingness of the parent to care for the child, it uses a balancing test—by accepted premise, the rights of each parent are considered to be equal, so the Court will balance and compare the relative abilities and willingness of each parent to care for the child. Lack of interest in the child or motivation to parent, as well as a history of not carrying out parenting tasks, will be relevant to the Court’s comparison.
Note that there are some additional factors which might be at play here and relate to caring for the child: for example, the court might look at the suitability of the parent’s residence, the lifestyle of the parent, and any abuse, substance abuse, or violence. If emotional or mental health issues have interfered with the parent’s ability to provide a safe and stable residence, for example, or perhaps escalated into abuse or violence in the past, then the Court may consider those factors. Or, if emotional or mental health issues have caused serious substance abuse by the parent, the Court again will consider that factor. However, in and of itself, taking lawfully prescribed medication for mental health issues will not disqualify a parent from being awarded custody.
3. Health of the Parent and Medication
Obviously, the physical, mental, and emotional health of each parent is a significant factor in making decisions regarding custody. In several cases, the Court considered the mental or emotional instability of a parent as a decisive factor in awarding custody to the other side. 
However, neither physical nor mental illness of the parent will automatically disqualify the parent from custody—rather, it is relevant ONLY when those issues adversely affect the child, or where the parent cannot adequately carry out his or her parenting responsibilities.
 Angelone v. Angelone, 9 Mass. App. Ct. 728 (1980).
 In re Laurent, 87 Mass. App. Ct. 1 (2015).
 Adoption of Jacques, 82 Mass.App.Ct. 601 (2012).
 In re Adoption of Sunil, 79 Mass.App.Ct. 1112 (2011).
 See Fort v. Fort, 12 Mass. App. Ct. 411 (1981); Sloane v. Sloane, 349 Mass. 318 (1965); and In re Stephen, 401 Mass. 144 (1987).