Competition between commensal and pathogenic microbes for monosaccharides derived from mucus layer O-glycans as nutrient sources has been proposed as a mechanism by which the gut microbiota counteracts pathogen colonization. However, our understanding of the microbial interactions that determine competition for these sugars in complex microbial communities, and how to exploit such information to develop therapies, is limited. Here, we employed heavy water (D2O)-based activity labeling followed by automated Raman-Activated Cell Sorting of active (D-labeled) cells and metagenomics to identify mouse gut commensals that forage on O-glycan monosaccharides. Sequencing of cell-sorted fractions revealed members of the underexplored family Muribaculaceae as major mucin monosaccharide foragers, followed by members of Lachnospiraceae, Rikenellaceae and Bacteroidaceae families. We further show that the ability of these organisms to forage on mucosal sugars is well-supported by the presence of partial or complete catabolism pathways for O-glycan utilization in their genomes. Remarkably, administration of a 5-member bacterial consortium based on identified sialic acid and N-acetylglucosamine utilizers results in limited access of the gut pathogen Clostridioides difficile to mucosal sugars and in impaired pathogen colonization of antibiotic-treated mice. Our findings underscore the value of using targeted approaches to identify organisms performing key functions in the gut and to rationally design effective probiotic mixtures.