Foodborne heterocyclic aromatic amines (HAAs) are potent mutagens and carcinogens, posing significant health risks. Existing enrichment methods for HAAs need better adsorption selectivity and capacity for daily exposure assessment. This study hypothesized that introducing carboxylic groups into magnetic covalent organic frameworks (m-COFs) would improve HAAs adsorption by providing additional binding sites. Hence, we prepared a novel magnetic adsorbent, termed as Fe3O4@DOPA-TpPa-(COOH)2 capable of enhancing the HAAs detection through magnetic solid-phase extraction (MSPE) coupled with UPLC-MS. This sorbent demonstrated a large specific surface area (130.7 m2/g), high magnetic responsivity (21.05 emu/g), and robust stability, with an adsorption capacity (Qm[cal]: 81.82 mg/g) driven by electrostatic, LP − π/C-H − π interactions, and hydrogen bonding. Optimal MSPE conditions provided sensitive detection with a broad linear range (5–500 ng/mL), low limits of detection (0.01–7.01 ng/g), and excellent repeatability. Application to Cantonese mooncake samples showed satisfactory recoveries (62.12%–126.86%). This method offers a more accurate tool for detecting HAAs.