Regulating the coordination environment of metal–Nx species by replacing N with low electronegativity atoms is an approach of tuning the electrocatalytic performance of metal-based sites. However, such effects on the enhancement of photocatalytic H2 evolution over semiconductors are not discussed yet. Herein, we designed and prepared Co-based cocatalysts with controlled coordination environment via calcination Co/ZIF-8 loaded with triphenylphosphine followed by a sulfurization treatment. It was then used as cocatalyst to modify CdS. The effects of the coordination environment of Co atoms on the H2 evolution activity of CdS were discussed. The obtained Co was co-stabilized by N, P, and S atoms and embedded in graphitic carbon (denoted as Co-NxPS/C). Experimental results indicated that the Co-NxPS/C exhibited high activity in enhancing H2 evolution of CdS with a value of 1260 μmol after 5 h irradiation. The simultaneous replacement of N with P and S atoms in N-stabilized Co embedded in carbon could enhance light harvesting, accelerate the transfer of photogenerated electrons from CdS to carbon with increased electrons accumulation ability and conductivity, improve charge separation efficiency, and enhance proton reduction kinetics. It is believed that the results of this study could promote the development of other high performance MOF-derived atomically dispersed cocatalysts to increase photocatalytic H2 evolution.