The consequences of magnetohydrodynamic flow inside the boundary layer of a Jeffery fluid in a porous material across a shrinking/stretching sheet are discussed in this paper. The Runge–Kutta fourth-order technique is used to turn partial differential equations into nonlinear ordinary differential equations and solve them using similarity transformation. On the velocity and temperature profiles, the effects of key factors such as “thermal stratification”
e
1
,
λ
1
“Jeffery parameter,” Pr “Prandtl number”, M “Magnetic field,” “Porous parameter”
λ
2
, and “heat generation/absorption” have been visually described. In terms of heat transmission, the Jeffrey nanofluid beats other fluids such as Oldroyd-B and Maxwell nanofluids, according to the findings. According to our findings, the thickness of the boundary layer is explored in both stretching and shrinking. When the “thermal stratification”
e
1
parameter is increased, fluid velocity and temperature rise, while the “heat generation/absorption”
γ
parameter has the opposite effect.