Nowadays, the development of smart grids has been the focus of attention due to its advantages for power systems. One of the aspects of smart grids defined by using distributed generation (DG) in a low voltage network is a microgrid (MG). Based on its operational states, MG can operate in different configurations such as grid-connected mode or off-grid mode. The switching between these states is one of the challenging issues in this technical area. The fault currents in different buses have higher value compared to islanded mode of MG when the MG is connected to the main grid, which influences the protection equipment. In this situation, some electrical devices may be damaged due to the fault currents. Application of a fault current limiter (FCL) is considered as an effective way to overcome this challenge. The optimal size of these FCLs can optimize the performance of an MG. In this paper, an index for FCL size optimization has been used. In addition, two optimization algorithms (Bat Algorithm and Cuckoo Search Algorithm) have been applied to the problem. The application of an FCL has been studied in grid-connected and islanded-mode. In addition, the application of the capacitor bank in both modes has been investigated. The results of simulations carried out by MATLAB have been presented and compared.