Heavy metals in food and water sources are potentially harmful to humans. Determination of these pollutants is critical for improving safety. Effective recognition systems are a contemporary challenge; several novel technologies for the quick, easy, selective, and sensitive determination of these compounds are in demand. Metal–organic framework (MOF)-based sensors and biosensors have crucial applications in identifying these potentially harmful substances. Here, we review electrochemical and optical biosensors for in situ sensing that are sensitive and cost effective, with a simple protocol and wide linear range. Despite the abundance of articles in this field, we assessed and checked out various basic features of MOFs as porous compounds that include clusters or ions, and some of the ligands connected to these clusters have a variety of useful properties. Afterward, we also assessed various electrochemical and optical sensing assays, which have recently gathered interest because of their potential applications for recognizing certain compounds in the environment. Their operation and approaches are dependent on their structures, the materials and component types used, and the substances they are targeting.