We performed neutron-diffraction experiments and density functional theory calculations to study the magnetostructural coupling in MnCoGeBx (x=0, 0.01, and 0.05) alloys. By varying the amount of boron addition, we are able to freely switch the magnetostructural coupling on and off in the MnCoGe alloys. It is found that the boron addition stabilizes the high-temperature hexagonal phase due to the reduced interatomic distances and the enhanced covalent bonding. The hexagonal-orthorhombic structural transition shifts to low temperatures with the boron addition and coincides with the paramagnetic-ferromagnetic (PM-FM) transition in the MnCoGeB0.01 alloy. With a further increase in the boron addition, the structural and magnetic transitions are decoupled again. The hexagonal-orthorhombic structural transition is significantly suppressed in the MnCoGeB0.05 alloy, although subtle distortions in the hexagonal structure are evidenced by a canted spin arrangement below 75 K. The MnCoGe and MnCoGeB0.01 alloys show a collinear FM structure, having a much larger Mn moment than the MnCoGeB0.05 alloy. The relatively small Mn moment in the MnCoGeB0.05 alloy can be attributed to the shortened Mn-Mn distance and the enhanced overlap of the 3d orbitals between the neighboring Mn atoms. The uncovered relationship between the structural evolution and the sizable magnetic moment in the present work offers more insight into the magnetostructural coupling in the MnCoGe-based alloys.