A heterostructure of bimetallic copper/ferric metal–organic framework embedded with ferric oxide (denoted as Fe2O3@CuFe-MOF) nanocrystals was simultaneously employed as the bioplatform for constructing the photoelectrochemical (PEC) aptasensor to detect miRNA-141 and an excellent contrast agent for in vivo diagnosis cancer via magnetic resonance imaging (MRI). Fe2O3@CuFe-MOF was synthesized by linking 5,10,15,20-tetra(4-pyridyl)porphyrin (TPyP) with Cu2+ and Fe2+ ions, while partial Fe2+ ions were oxidized to Fe2O3 nanocrystals and embraced within CuFe-MOF (denoted as Fe2O3@CuFe-TPyP-MOF). Comparing with Cu-TPyP-MOF and Fe2O3@Fe-TPyP-MOF, Fe2O3@CuFe-TPyP-MOF exhibited enhanced separation ability of photocarriers, promoted electron transfer, larger specific surface area, and richer functionality, rendering boosted photoelectric conversion efficiency and superior PEC performance. The Fe2O3@CuFe-TPyP-MOF-based PEC aptasensor thus illustrated an ultralow limit of detection (0.8 fM) toward miRNA-141 within a wide range from 1.0 fM to 1.0 nM, accompanying with other outperformed aptasensing ability. In addition, due to the paramagnetic property of Cu2+ and Fe2+ ions, Fe2O3@CuFe-TPyP-MOF also afforded the promoted T1-weighted MRI imaging ability, showing the potential for the diagnosis of prostate tumor in vivo. This work provides a robust photoelectronic active MOF-based heterostructure for the sensitive detection and early cancer diagnosis.