  We prove a sharp Poincar\'e inequality for subsets $\Omega$ of (essentially
non-branching) metric measure spaces satisfying the Measure Contraction
Property $\textrm{MCP}(K,N)$, whose diameter is bounded above by $D$. This is
achieved by identifying the corresponding one-dimensional model densities and a
localization argument, ensuring that the Poincar\'e constant we obtain is best
possible as a function of $K$, $N$ and $D$. Another new feature of our work is
that we do not need to assume that $\Omega$ is geodesically convex, by
employing the geodesic hull of $\Omega$ on the energy side of the Poincar\'e
inequality. In particular, our results apply to geodesic balls in ideal
sub-Riemannian manifolds, such as the Heisenberg group.
