This paper presents the development and validation of a Magnetohydrodynamics (MHD) module integrated into the Xcompact3d framework, an open-source high-order finite-difference suite of solvers designed to study turbulent flows on supercomputers. Leveraging the Fast Fourier Transform library already implemented in Xcompact3d, alongside sixth-order compact finite-difference schemes and a direct spectral Poisson solver, both the induction and potential-based MHD equations can be efficiently solved at scale on CPU-based supercomputers for fluids with strong and weak magnetic field, respectively. Validation of the MHD solver is conducted against established benchmarks, including Orszag-Tang vortex and MHD channel flows, demonstrating the module's capability to accurately capture complex MHD phenomena, providing a powerful tool for research in both engineering and astrophysics. The scalability of the Xcompact3d framework remains intact with the incorporation of the MHD module, ensuring efficient performance on modern high-performance clusters. This paper also presents new findings on the evolution of the Taylor-Green vortex under an external magnetic field for different flow regimes.