Microorganisms exist in large communities of diverse species, exhibiting various functionalities. The mammalian gut microbiome, for instance, has the functionality of digesting dietary fibre and producing different short-chain fatty acids. Not all microbes present in a community contribute to a given functionality; it is possible to find a minimal microbiome, which is a subset of the large microbiome, that is capable of performing the functionality while maintaining other community properties such as growth rate and metabolite production. Such a minimal microbiome will also contain keystone species for SCFA production in that community. In this work, we present a systematic constraint-based approach to identify a minimal microbiome from a large community for a user-proposed function. We employ a top-down approach with sequential deletion followed by solving a mixed-integer linear programming problem with the objective of minimising the L1-norm of the membership vector. Notably, we consider quantitative measures of community growth rate and metabolite production rates. We demonstrate the utility of our algorithm by identifying the minimal microbiomes corresponding to three model communities of the gut, and discuss their validity based on the presence of the keystone species in the community. Our approach is generic, flexible and finds application in studying a variety of microbial communities. The algorithm is available from https://github.com/RamanLab/minMicrobiome.