Structure of the electrode materials play a critical role in electrochemical performance for both lithium-ion batteries and sodium ion batteries. Herein, MXene modified by element doping and compositing metal–organic frameworks (MOF)-based Fe2O3@Carbon nanofibers (CNFs) with a mezzanine heterostructure, is constructed to achieve low interfacial impedance, high specific capacity stability in lithium/sodium storage processes. The prepared mezzanine heterostructure Fe2O3@C@N-Ti3C2Tx composite is highly conductive and mesoporous. During the nitrogen-doping thermal treatment process, the interlayer spacing of Ti3C2Tx MXene was increased, providing wider ion transport channels. Additionally, inert carbon atoms were transformed into electrochemically active nitrogen atoms, leading to the construction of more active centers and surface defects. The spatial confinement of N-Ti3C2Tx MXene during the electrochemical process, effectively mitigating volume expansion and maintaining structural stability upon applied as electrode materials. Benefitting from the unique 3D conductive network, the mezzanine heterostructure Fe2O3@C@N-Ti3C2Tx composite nanofibers exhibits excellent Li/Na storage performance. In LIBs, it delivers a capacity of 226 mAh/g at 10 A/g and retains 314 mAh/g after 2800 ultra-long cycles at 5 A/g. For SIBs, it exhibits a capacity of 135 mAh/g at 5 A/g and maintains 209 mAh/g after 3000 cycles at 2 A/g.