Carbon materials stand out as anode materials in both lithium-ion batteries and potassium-ion batteries as they are capable of sustaining stable electrochemical cycles, yet limited reversible capacities hinder their further development for practical applications. In this work, carbon materials are rationally designed to integrate with metal sulfides, resulting in a structure of metal-catalyzed nitrogen and sulfur-codoped carbon nanotube-encapsulated Co9S8 nanoparticles. Synthesized by sequential chemical vapor deposition and a sulfidation process, this hybrid structure exhibits high capacities for lithium and potassium storage while maintaining long cycling stability. As a lithium-ion/potassium-ion battery anode, the hybrid delivers a reversible specific capacity (808/429 mA h g-1 at 0.1 A g-1), great rate performance (437/145 mA h g-1 at 10 A g-1), and excellent cyclability. Furthermore, a lithium-ion/potassium-ion hybrid capacitor utilizing this anode can attain substantial energy density and elevated power density (89 W h kg-1/136 W h kg-1 at 4750 W kg-1/1280 W kg-1) simultaneously. Detailed kinetic analyses show that the excellent electrochemical performance originates from a synergistic effect of Co9S8 and functional carbon at a certain ratio. This work may provide useful insights for the application of carbon-based anodes that chemically integrated with metal sulfides for electrochemical energy storage.