In electric power systems, any deviation with respect to the theoretical sinusoidal waveform is considered to be a disturbance in the power quality of the electrical grid. The deviation can alter any of the parameters of the waveform: frequency, amplitude, and symmetry among phases. Microgrid, as a part of the electric power system, has to contribute providing an adequate current waveform in grid connected-mode, as well as to guarantee similar voltage features than the standard requirement given for public distribution grids under normal exploitation conditions in islanded mode. Adequate power quality supply is necessary for the correct compatibility between all the devices connected to the same grid. In this paper, the power quality of microgrids is managed using a Model Predictive Control (MPC) methodology which regulates the power converters of the microgrids in order to achieve the requirements. The control algorithm is developed for the following microgrids working modes: grid-connected, islanded, and interconnected. The simulation results demonstrate that the proposed methodology improves the transient response in comparison with classical methods in all the working modes, minimizing the harmonic content in the current and the voltage even with the presence of non-balanced and non-harmonic-free three-phase voltage and current systems.