BackgroundSpermatogenic dysfunction is an important cause of azoospermia. Numerous studies have focused on germ-cell-related genes that lead to spermatogenic impairment. However, based on the immune-privileged characteristics of the testis, the relationship of immune genes, immune cells or immune microenvironment with spermatogenic dysfunction has rarely been reported.ResultsUsing integrated methods including single-cell RNA-seq, microarray data, clinical data analyses and histological/pathological staining, we found that testicular mast cell infiltration levels were significantly negatively related to spermatogenic function. We next identified a functional testicular immune biomarker, CCL2, and externally validated that testicular CCL2 was significantly upregulated in spermatogenic dysfunctional testes and was negatively correlated with Johnsen scores (JS) and testicular volumes. We also demonstrated that CCL2 levels showed a significant positive correlation with testicular mast cell infiltration levels. Moreover, we showed myoid cells and Leydig cells were two of the important sources of testicular CCL2 in spermatogenic dysfunction. Mechanistically, we drew a potential “myoid/Leydig cells-CCL2-ACKR1-endothelial cells-SELE-CD44-mast cells” network of somatic cell–cell communications in the testicular microenvironment, which might play roles in spermatogenic dysfunction.ConclusionsThe present study revealed CCL2-relevant changes in the testicular immune microenvironment in spermatogenic dysfunction, providing new evidence for the role of immunological factors in azoospermia.Supplementary InformationThe online version contains supplementary material available at 10.1186/s13578-023-01034-2.