Piezoelectric energy harvesting of mechanical waves exhibits great potential applications in electricity generation for low-powered electronic devices. In this work, the metasurface-assisted phononic cavity is proposed for the enhancement of piezoelectric energy harvesting of elastic flexural waves. By employing the two-dimensional plate-type metamaterial, we construct a phononic cavity that possesses the ability to localize and amplify the flexural waves. On the other hand, for the purpose of flexural wave focusing, a sparse metasurface is inversely designed based on the interference theory through the particle swarm optimization algorithm. For collaborative wave manipulation, the sparse metasurface is set in front of the phononic cavity. Additionally, piezoelectric patches are attached within the phononic cavities. The wave characteristics of the metasurface-assisted phononic cavity are studied by using the finite element method. For comparison, a conventional phononic cavity (i.e., cavity without metasurface) and a reference bare plate are also considered. Due to the wavefront control ability of the metasurface, more flexural waves are guided into the phononic cavity region. Thus, compared with the reference plate, the power amplification ratios of the metasurface-assisted cavity and the conventional cavity are 102 and 7, respectively. The electrical outputs of the phononic cavity are remarkably boosted by the assistance of the sparse metasurface.