The microbiome is a predictor of clinical outcome in patients receiving allogeneic hematopoietic stem cell transplantation (allo-SCT). Microbiota-derived metabolites can modulate these outcomes. How bacteria, fungi and viruses contribute to the production of intestinal metabolites is still unclear. We combined amplicon sequencing, viral metagenomics and targeted metabolomics from stool samples of patients receiving allo-SCT (n = 78) and uncovered a microbiome signature of Lachnospiraceae and Oscillospiraceae and their associated bacteriophages, correlating with the production of immunomodulatory metabolites (IMMs). Moreover, we established the IMM risk index (IMM-RI), which was associated with improved survival and reduced relapse. A high abundance of short-chain fatty acid-biosynthesis pathways, specifically butyric acid via butyryl-coenzyme A (CoA):acetate CoA-transferase (BCoAT, which catalyzes EC 2.8.3.8) was detected in IMM-RI low-risk patients, and virome genome assembly identified two bacteriophages encoding BCoAT as an auxiliary metabolic gene. In conclusion, our study identifies a microbiome signature associated with protective IMMs and provides a rationale for considering metabolite-producing consortia and metabolite formulations as microbiome-based therapies.