In this study, a filter was fabricated by integrating molecularly imprinted polymer technology with carbon dots, and it was utilized for the extraction of atorvastatin. Data analysis was performed using high-performance liquid chromatography with ultraviolet detection. Furthermore, the structure of the synthesized sorbent was characterized by Fourier transform infrared spectroscopy, field emission-scanning electron microscopy, x-ray diffraction, and nitrogen adsorption-desorption analysis. The optimization of the extraction parameters was carried out using response surface methodology based on the Box–Behnken design. A linear range of 0.2–800 µg/L was obtained for atorvastatin, with a coefficient of determination (R2) of 0.9985. The limits of detection and quantification were calculated to be 0.09 and 0.30 µg/L, respectively. The efficiency of the proposed method was evaluated in urine and blood serum samples, and recoveries of more than 91.9% and relative standard deviations less than 5.8% were obtained.