Uveal melanoma arises from stromal melanocytes and is the most prevalent primary intraocular tumor in adults. It poses a significant diagnostic and therapeutic challenge due to its high malignancy and early onset of metastases. In recent years, there has been a growing interest in the role of diverse immune cells in tumor cell development and metastasis. Using The Cancer Genome Atlas and the gene expression omnibus databases, and the CIBERSORT method, we investigated the topography of intra-tumor immune infiltration in uveal melanoma in this research. We evaluated the prognosis of uveal melanoma patients using the M2 macrophage immune cell infiltration score in conjunction with clinical tumor patient data. We built a prognostic model based on the distinctive genes of M2 macrophages and combined it with patients’ clinical data in the database; we ran a survival prognostic analysis to authenticate the model’s accuracy. The functional study revealed the importance of macrophage-associated genes in the development of uveal melanoma. Moreover, the reliability of our prediction model was verified by combining tumor mutational load, immune checkpoint, and drug sensitivity, respectively. Our study provides a reference for the follow-up study of uveal melanoma.Supplementary InformationThe online version contains supplementary material available at 10.1186/s12859-023-05396-9.