This study aimed to design and synthesize a novel adsorbent Fe3O4@SiO2@MPA-TAPA-COF material for the first time and used as an adsorbent of MSPE. It had significant potential for the pretreatment of trace analytes. The MSPE was coupled with ultra performance liquid chromatography–tandem mass spectrometry (UPLC-MS/MS) for the rapid extraction and detection of 12 sulfonamides (SAs) from water and milk samples for the first time. Several experimental parameters were optimized, including adsorbent dosage and the effects of pH, ionic strength, adsorption time, and desorption conditions. Under the optimized pretreatment and instrumental conditions, good linearity of 0.1–100 μg·L−1 with a correlation coefficient 0.9994–0.9999, low limits of detection (0.004–0.044 μg·L−1) and limits of quantitation (0.013–0.136 μg·L−1) were obtained. Moreover, the recoveries of sulfonamides in water and milk samples were in the range of 60.88 %-102.94 %, and the relative standard deviations not exceeding 9.62 %. Finally, the magnetic Fe3O4@SiO2@MPA-TAPA-COF material possessed the magnetic separation and high adsorption affinity for extracting SAs from real samples. This study holds great significance in enhancing the monitoring of SAs drug residues in water and milk.