Microgrids can be controlled to optimize the generation and consumption of energy in a bounded geographical area which, in the global current scenario, facilitates the integration of distributed energy resources to the main grid. Additionally, some ancillary services, such as support of grid instabilities or power quality improvements, can be also obtained modifying the microgrid control scheme. In this paper, the compensation of reactive power and harmonic components in the main grid current using the microgrid interface converter is proposed. Using predictive current control for fast dynamical response and an energy-based model to avoid linear approximation the microgrid converter works as an active filter while the microgrid DC bus is regulated to the desired voltage. Simulations results for a 80 kW microgrid connected to the main grid is presented to support theoretical analysis.