  We investigate the impact of environment on the internal mass distribution of
galaxies using the Middle Ages Galaxy Properties with Integral field
spectroscopy (MAGPI) survey. We use 2D resolved stellar kinematics to construct
Jeans dynamical models for galaxies at mean redshift $z \sim 0.3$,
corresponding to a lookback time of $3-4$ Gyr. The internal mass distribution
for each galaxy is parameterised by the combined mass density slope $\gamma$
(baryons $+$ dark matter), which is the logarithmic change of density with
radius. We use a MAGPI sample of 28 galaxies from low-to-mid density
environments and compare to density slopes derived from galaxies in the high
density Frontier Fields clusters in the redshift range $0.29 <z < 0.55$,
corresponding to a lookback time of $\sim 5$ Gyr. We find a median density
slope of $\gamma = -2.22 \pm 0.05$ for the MAGPI sample, which is significantly
steeper than the Frontier Fields median slope ($\gamma = -2.01 \pm 0.04$),
implying the cluster galaxies are less centrally concentrated in their mass
distribution than MAGPI galaxies. We also compare to the distribution of
density slopes from galaxies in Atlas3D at $z \sim 0$, because the sample
probes a similar environmental range as MAGPI. The Atlas3D median total slope
is $\gamma = -2.25 \pm 0.02$, consistent with the MAGPI median. Our results
indicate environment plays a role in the internal mass distribution of
galaxies, with no evolution of the slope in the last 3-4 Gyr. These results are
in agreement with the predictions of cosmological simulations.
