Convective self-aggregation refers to a phenomenon that random convection can self-organize into large-scale clusters over an ocean surface with uniform temperature in cloud-resolving models. Understanding its physics provides insights into the development of tropical cyclones and the Madden-Julian Oscillation. Here we present a vertically resolved moist static energy (VR-MSE) framework to study convective self-aggregation. We find that the development of self-aggregation is associated with an increase of MSE variance in the boundary layer (BL). We further show that radiation dominates the generation of MSE variance, which is further enhanced by atmospheric circulations. Surface fluxes, on the other side, consume MSE variance and then inhibits self-aggregation. These results support that the BL plays a key role in the development of self-aggregation, which agrees with recent numerical simulation results and the available potential energy analyses. Moreover, we find that the adiabatic production of MSE variance due to circulation mainly comes from the near-surface layer rather than the low-level circulation emphasized by previous literature. This new analysis framework complements the previous MSE framework that does not resolve the vertical dimension.