Microglia/macrophages (MG/Mφ) play a central role in the pathogenesis of multiple sclerosis (MS). However, the intricacies of the immunomodulatory microenvironment in MS, particularly the heterogeneity and regulatory mechanisms of MG/Mφ subpopulations, remain elusive. The commonly used treatment options for MS have several drawbacks, such as significant side effects and uncertain efficacy. The exploration of developing new drugs targeting MG/Mφ for the treatment of MS remains to be investigated. We identified three distinct subpopulations of MG/Mφ, among which MG/Mφ_3 significantly increased as the experimental autoimmune encephalomyelitis (EAE) progressed. Ifenprodil and RO-25-6981 demonstrated notable inhibition of inflammatory factor expression, accompanied by reduced cytotoxicity. The interaction modes of these compounds with the common binding pocket in the GluN1b-GluN2B amino terminal domain heterodimer were elucidated. Virtual docking, based on the N-methyl-D-aspartate (NMDA) receptor, showed that homo-skeleton compounds of ifenprodil potentially exhibit low binding free energy with the receptor, including eliprodil and volinanserin. In vitro cell models corroborated the effective inhibition of inflammatory factor expression and minimal cytotoxicity of eliprodil and volinanserin. CoMFA (standard error of estimate = 0.378, R2 = 0.928, F values = 241.255, Prob. of R2 = 0) and topomer CoMFA (q2 = 0.553, q2 stderr = 0.77, intercept = - 1.48, r2 = 0.908, r2 stderr = 0.35) were established based on the inhibitors of NMDA receptor. The contour maps of CoMFA and topomer CoMFA models give structural information to improve the inhibitory function. This study underscores the involvement of MG/Mφ in inflammatory pathways during MS progression and offers promising compound candidates for MS therapy targeting MG/Mφ.