Myocardial infarction, a type of coronary artery disease, results from various factors such as genetic predisposition, lifestyle choices, and immune system regulation. The exact causal links between immune cells, plasma metabolites, and myocardial infarction are currently unclear. Therefore, our study employed the Mendelian randomization approach to explore these potential causal relationships. To investigate the impact of immune cells on the risk of myocardial infarction mediated by alterations in plasma metabolite levels, we employed the Mendelian randomization (MR) framework. Our analysis utilized 5 distinct MR techniques (inverse variance weighted [IVW], weighted median, MR-Egger, simple mode, and weighted mode) to evaluate causal relationships among 731 immune cell types, 1400 plasma metabolites, and myocardial infarction. Genetic instruments for immune cells and metabolites were identified using data from a meta-analysis of genome-wide association studies. Furthermore, sensitivity analyses were performed to verify the robustness of our results, identify potential heterogeneity, and examine possible pleiotropic effects. IVW results indicated that IgD-CD38br lymphocytes was a risk factor for myocardial infarction, whereas IgD-CD38br lymphocytes also acted as a protective factor against myocardial infarction. Additionally, the glycerol to palmitoylcarnitine (C16) ratio was identified as a protective factor for myocardial infarction. IgD-CD38br lymphocytes could exert a detrimental effect on myocardial infarction by negatively regulating the glycerol to palmitoylcarnitine (C16) ratio, with the mediation effect ratio being 9%. IgD-CD38br lymphocytes potentially increase the risk of myocardial infarction by negatively affecting the glycerol to palmitoylcarnitine (C16) ratio. This finding opens avenues for developing early diagnostic tools and targeted therapies for myocardial infarction.