We present a QCD calculation of the $u$, $d$ and $s$ scalar quark contents of nucleons based on $47$ lattice ensembles with $N_f = 2+1$ dynamical sea quarks, $5$ lattice spacings down to $0.054,text{fm}$, lattice sizes up to $6,text{fm}$ and pion masses down to $120,text{MeV}$. Using the Feynman-Hellmann theorem, we obtain $f^N_{ud} = 0.0405(40)(35)$ and $f^N_s = 0.113(45)(40)$, which translates into $sigma_{pi N}=38(3)(3),text{MeV}$, $sigma_{sN}=105(41)(37),text{MeV}$ and $y_N=0.20(8)(8)$ for the sigma terms and the related ratio, where the first errors are statistical and the second are systematic. Using isospin relations, we also compute the individual up and down quark contents of the proton and neutron (results in the main text).