Introduction of renewable energy sources (RESs) and independently operated multi-microgrid (MMG) systems have led to new issues in the management of power systems. In this context, uncertainty associated with RESs as well as intense ramps inflicted on the network called system flexibility constraints have raised new challenges in power systems. The new condition necessitates the implementation of novel frameworks that enable local system operators to efficiently manage the available resources to cope with the flexibility-ramp constraints. Moreover, the new framework should facilitate energy management in a system with an MMG structure considering uncertainty of RESs. Consequently, in this article, we aim to provide a novel framework that composes of a two-level stochastic optimization procedure to optimize the energy management in an MMG, considering uncertainty of RESs as well as grid flexibility constraints. In the proposed scheme, resource scheduling in microgrids (MGs) is conducted in the first level by their control units, while the second-level procedure focuses on the coordination of MGs, considering flexibility constraints. Furthermore, interaction with gas grid as a potential flexible resource is optimized in the second-level procedure. Finally, the provided flexibility-oriented management scheme is implemented to schedule the local resources in a three-MG test system, considering flexibility constraints.