Controllable pyrolysis of metal-organic frameworks (MOFs) in confined spaces is a promising strategy for the design and development of advanced functional materials. In this study, Co-Co3O4@carbon composites were synthesized via pyrolysis of a Co-MOFs@glucose polymer (Co-MOFs@GP) followed by partial oxidation of Co nanoparticles (NPs). The pyrolysis of Co-MOFs@GP generated a core–shell structure composed of carbon shells and Co NPs. The controlled partial oxidation of Co NPs formed Co-Co3O4 heterojunctions confined in carbon shells. Compared with Co-MOFs@GP and Co@carbon-n (Co@C-n ), Co-Co3O4@carbon-n (Co-Co3O4@C-n ) exhibited higher catalytic activity during NaBH4 hydrolysis. Co-Co3O4@C-II provided a maximum specific H2 generation rate of 5, 360 mL·min-1·gCo-1 at room temperature due to synergistic interactions between Co and Co3O4 NPs. The Co NPs also endowed Co-Co3O4@C-n with the ferromagnetism needed to complete the magnetic momentum transfer process. This assembly-pyrolysis-oxidation strategy may be an efficient method of preparing novel nanocomposites.