Rooftop solar power systems refer to the organization of photovoltaic (PV) panels on the rooftop of a building. They are a feasible substitute for land-based solar arrays, and they are being used in different Asian countries. Thus regulations, grid connectivity, off-take, and land acquisition are the main obstacles that renewable energy plant owners face. At high penetration of rooftop PV, this voltage variability reduces the stability of the grid due to transient imbalance in load and generation and causes voltage and frequency to exceed set limits if not countered by power controls. To reduce this power loss in the transmission cable, a Manta Ray Foraging Optimization (MRFO) process is presented in this research. This method also enhances the PV system's performance. A Non-isolated Buck-Boost Converter is connected between the PV and the grid. For renewable energy applications, a new non-isolated Buck-Boost converter with high voltage gain and positive output voltage has been developed. This converter receives the voltage of input from the PV and gives the output as boosting or lowering the voltage. To improve the current tracking with high power conversion efficiency, a Finite Control Set Model Predictive Controller (FCS-MPC) is introduced for this converter. The proposed optimization algorithm is utilized to tune the controller and improves the dynamic process of the power plant system connected to the grid. This algorithm is simulated using the Matlab Simulink software. The voltage and power generated by the proposed rooftop PV are 560 V and 495.25 kW/sec. The voltage and electricity produced by the ground-mounted are very low compared to the proposed method, therefore, utilizing this rooftop solar PV model, that study generates more power than the ground-mounted PV. This study contributes to the field by improving the energy production of roof-top solar PV systems based on roof design.