High expression of cyclooxygenase-2 (COX-2) in the inflammatory tumor microenvironment is a critical target for early cancer diagnosis. We designed and synthesized a series of near-infrared (NIR) fluorescent probes based on the aggregation-induced emission (AIE) mechanism for targeted COX-2 imaging. Leveraging a D-π-A quinoline-malononitrile core, we developed probes YL-180 (non-targeted control), YL-181 (celecoxib conjugate), and YL-186 (indomethacin conjugate). Notably, this work represents the first report combining this specific AIE core with established COX-2 targeting ligands, celecoxib and indomethacin, for this application. These probes exhibit characteristic AIE properties, with YL-181 showing fluorescence enhancement up to approximately 9.7-fold from pure THF in aggregated state, effectively overcoming the aggregation-caused quenching (ACQ) issue. They also possess favorable optical features including NIR emission (>650 nm) and large Stokes shifts (>200 nm). Their aggregation behavior and nanoparticle formation were characterized by DLS and TEM. In vitro cellular imaging revealed that YL-181 achieved superior tumor cell selectivity, demonstrating approximately 22-fold higher fluorescence intensity in MCF-7 cancer cells over normal HUVEC cells (around 4-fold for YL-186 over normal HUVEC cells). A competitive assay confirmed YL-181's specific COX-2 binding. Furthermore, YL-181 sensitively reflected intracellular COX-2 levels, with fluorescence decreasing by approximately 97 % from untreated upon COX-2 inhibition and increasing by around 135 % from untreated upon induction. Molecular docking and dynamics simulations provided insights into the specific binding mode and dynamic stability of YL-181 with COX-2 from an atomic perspective. In vivo imaging validated YL-181's excellent tumor targeting ability and high contrast performance in mouse models, showing a tumor-to-background ratio (TBR) of around 1.83 from normal tissue background, consistent with ex vivo organ analysis. Our highly sensitive and selective COX-2 targeted AIE probe, YL-181, holds significant potential for precise early tumor imaging.