Modular optimization of metal-organic frameworks (MOFs) was realized by incorporation of coordinatively unsaturated single atoms in a MOF matrix. The newly developed MOF can selectively capture and photoreduce CO2 with high efficiency under visible-light irradiation. Mechanistic investigation reveals that the presence of single Co atoms in the MOF can greatly boost the electron-hole separation efficiency in porphyrin units. Directional migration of photogenerated excitons from porphyrin to catalytic Co centers was witnessed, thereby achieving supply of long-lived electrons for the reduction of CO2 molecules adsorbed on Co centers. As a direct result, porphyrin MOF comprising atomically dispersed catalytic centers exhibits significantly enhanced photocatalytic conversion of CO2 , which is equivalent to a 3.13-fold improvement in CO evolution rate (200.6 μmol g-1 h-1 ) and a 5.93-fold enhancement in CH4 generation rate (36.67 μmol g-1 h-1 ) compared to the parent MOF.