In this research, a composite of silver (Ag) nanoparticle-embedded covalent organic framework (Ag@COF) was synthesized with a simple and rapid reduction-based method. Then, the synthesized composite was characterized with scanning electron microscopy, X-ray diffraction, energy dispersive X-ray spectroscopy, Fourier-transform infrared spectroscopy, cyclic voltammetry, and electrochemical impedance spectroscopy techniques. Afterward, it was employed as an electrocatalytic modifier for highly sensitive and selective square wave anodic stripping voltammetric determination of Pb2+ and Cd2+ at ultra-trace levels. Besides, the effect of all of the effective experimental factors was optimized in order to achieve the highest sensitivity. Under optimized conditions (pH=3.0, deposition time=300 s, deposition potential= -1.3 (V)) the developed electrochemical sensor showed a linear response over a wide concentration range 20–120 and 30–300 nmol L−1 with detection limits of 6.9 and 11.1 nmol L−1 for Pb2+ and Cd2+ respectively. The selectivity of the proposed electrode over various ionic species was also scrutinized and no serious interference was observed. In the end, the designed electrochemical sensor was employed successfully for the determination of Pb2+ and Cd2+ ions at different edible specimens.