An important factor in the pathogenesis of polycystic ovary syndrome (PCOS) is chronic low-grade inflammation. However, the exact pathophysiology of PCOS is currently unknown, which makes clinical diagnosis and the development of effective treatments more difficult. We aimed to investigate the role of the inflammatory response in initiating and progressing PCOS. 13 control granulosa cell samples and 15 granulosa cell samples from patients with PCOS were obtained from the GSE102293, GSE34526, and GSE5850 datasets. The gene set variation analysis (GSVA) method was used to calculate the inflammatory response score. Subsequently, the genes associated with inflammation in the hub were identified using differential expression analysis and weighted gene co-expression network analysis (WGCNA). The findings were confirmed by analysis of independent datasets and examination of clinical samples by qRT-PCR analysis. A consensus cluster analysis was conducted to categorize the PCOS samples into subtypes related to inflammation. Functional enrichment and analysis of immune cell infiltration were conducted to explore the potential mechanisms involved. Additionally, the CMap database was utilized to predict potential drugs, and the results were confirmed through molecular docking. During the training cohort analysis, we identified five distinct genes (TGFBR2, ICAM3, WIPF1, SLC11A1, and NCF2) that could serve as potential diagnostic markers for PCOS. The expression levels of these genes were confirmed through validation in both the test set and clinical samples. In training cohort, two distinct inflammatory patterns (C1 and C2) were identified, and the C2 subtype exhibited activated immune- and inflammation-related pathways. Esmolol was shown to have potential as a drug to treat PCOS and it showed good results for molecular binding at TGFBR2, ICAM3, WIPF1, SLC11A1, and NCF2 proteins. Five diagnostic biomarkers and two inflammation-related molecular types associated with PCOS were identified, and esmolol was a potential drug for PCOS treatment. Our findings provided new diagnostic markers and potential small-molecule drugs for PCOS diagnosis and prevention.