We consider the magnetic interaction of manganese phtalocyanine (MnPc) absorbed on Pb layers that were grown on a Si substrate. We perform an ab initio calculation of the density of states and Kondo temperature as a function of the number of Pb monolayers. Comparison to experimental data [Y.-S. Fu et al., Phys. Rev. Lett. 99, 256601 (2007)] then allows us to determine the exchange coupling constant J between the spins of the adsorbed molecules and those of the Pb host. This approach gives rise to a general and reliable method for obtaining J by combining experimental and numerical results.