Species–energy theory can account for spatial variation in the abundance and community composition of animals, though the mechanisms of species–energy theory are under contention. We evaluated three competing mechanisms at the local spatial scale by conducting an in vivo light manipulation over supplemental ant nests placed in the leaf litter of a Costa Rican tropical rainforest. We found that the light environment did not alter the 10% rate of occupation of the supplemental nests, but light did alter the size of colonies and the genus-level composition of the community. Light levels in the foraging range were positively associated with colony sizes of all ants, whereas light levels directly on the nest site were predictive of the occurrence of ant genera. Colonies of specialized predators, dacetine ants, were larger in more shaded foraging environments, and the functional group of generalized myrmicines exhibited an opposite pattern, with smaller-sized colonies in response to shading. Responses of twig-dwelling ants to the light environment were most consistent with the metabolic cost hypothesis as a mechanism of species–energy theory. We found mixed support for the thermal energy availability hypothesis, and scant support for the chemical energy hypothesis, as the litter depth, a measure of prey density, was not predictive of ant responses. In summary, at the local scale, we found patterns in colony size and life history are governed by light-dependent mechanisms.