Obesity is strongly associated with the occurrence and development of many types of cancers. Patients with obesity and cancer present with features of a disordered gut microbiota and metabolism, which may inhibit the physiological immune response to tumors and possibly damage immune cells in the tumor microenvironment. In recent years, bariatric surgery has become increasingly common and is recognized as an effective strategy for long-term weight loss; furthermore, bariatric surgery can induce favorable changes in the gut microbiota. Some studies have found that microbial metabolites, such as short-chain fatty acids (SCFAs), inosine bile acids and spermidine, play an important role in anticancer immunity. In this review, we describe the changes in microbial metabolites initiated by bariatric surgery and discuss the effects of these metabolites on anticancer immunity. This review attempts to clarify the relationship between alterations in microbial metabolites due to bariatric surgery and the effectiveness of cancer treatment. Furthermore, this review seeks to provide strategies for the development of microbial metabolites mimicking the benefits of bariatric surgery with the aim of improving therapeutic outcomes in cancer patients who have not received bariatric surgery.