The ability to represent perturbative expansions of interacting quantum field theories in terms of simple diagrammatic rules has revolutionized calculations in particle physics (and elsewhere). Moreover, these rules are readily automated, a process that has catalyzed the rise of symbolic algebra packages. However, in the case of extended theories of gravity, such as scalar-tensor theories, it is necessary to precondition the Lagrangian to apply this automation or, at the very least, to take advantage of existing software pipelines. We present a Mathematica code FeynMG, which works in conjunction with the well-known package FeynRules, to do just that: FeynMG takes as inputs the FeynRules model file for a non-gravitational theory and a user-supplied gravitational Lagrangian. FeynMG provides functionality that inserts the minimal gravitational couplings of the degrees of freedom specified in the model file, determines the couplings of the additional tensor and scalar degrees of freedom (the metric and the scalar field from the gravitational sector), and preconditions the resulting Lagrangian so that it can be passed to FeynRules, either directly or by outputting an updated FeynRules model file. The Feynman rules can then be determined and output through FeynRules, using existing universal output formats and interfaces to other analysis packages. Program summaryProgram title: FeynMGCPC Library link to program files:https://doi.org/10.17632/bjpfmtt55k.1Developer's repository link:https://gitlab.com/feynmg/FeynMGLicensing provisions: MIT licenseProgramming language:Mathematica 13.2Nature of problem: Determining the additional interactions that scalar-tensor theories of gravity induce between the fields of the Standard Model of particle physics and its extensions is a tedious and time-consuming task that is ripe for automation. FeynMG is a package that provides this automation. It can expand the spacetime metric around a flat background and perform the necessary field redefinitions for a given theory in order to provide a Lagrangian that is in a form that can be processed by FeynRules[1]. The Feynman rules for the theory can then be determined using the existing functionality of FeynRules and output in formats that can be read into other particle-physics analysis packages.Solution method: (1) Load both FeynRules and FeynMG into Mathematica. (2) Load a model file describing a given matter sector and Lagrangian. (3) Use the FeynMG implementation to: (3a) append the gravitational sector and incorporate curvature-dependent objects, such as the metric, curvature scalars and tensors, and covariant derivatives; (3b) effect a Weyl transformation or expand the spacetime metric up to second order in graviton interactions with the matter fields; and (3c) diagonalize mass and kinetic mixings, and canonically normalize dynamical fields. (4) Pass the output directly to FeynRules or output a new model file from FeynMG.