Under the background of "double carbon" policy, the access of renewable energy in the power system has increased significantly, and the impact of its uncertainty on the system operation cannot be ignored. In order to improve the islanded microgrid's ability to cope with the uncertainty of renewable energy. Firstly, the index of matching degree of flexible supply and demand (MDFSD) is established based on flexibility margin theory, which is able to reflect the ability of the system to respond to load within a certain period of time. Then, the optimal operation model of microgrid is established, taking the operation cost and MDSDF index as the objective function, considering the constraints of power balance and equipment operation, and the multi-objective particle swarm optimization algorithm is used to solve it. Finally, the example analysis shows that the proposed model can effectively improve the system's ability to cope with uncertain output and improve economic benefits. The rationality and validity of the model are verified.