In this work, the effect of the functionalized Ni and Pd transition metals on interaction of the mercaptopyridine (MCP) with the boron nitride nanocage (B12N12) was investigated using the density functional theory (DFT) and TDDFT method. The selected structures were optimized using the camB3LYP/Lanl2DZ level of theory. The adsorption energy and enthalpy values of MCP on the surface of pristine, Ni, and Pd functionalized B12N12 nanocage were negative and all adsorption process were exothermic. The results of the recovery time indicated that the pristine B12N12 nanocage with the lowest recovery time was suitable for making sensitive sensor for MCP molecule and the Ni functionalized B12N12 with the most recovery time that was favorable for making the adsorbent of the MCP molecule. The reduced gradient density (RDG) and quantum theory of atom in molecule (QTAIM) outputs revealed that the interaction of MCP with the Ni functionalized B12N12 were stronger than that of the pristine model. The UV-visible results confirmed that the adsorption of MCP on the surface of the Ni functionalized B12N12 with the most value of λmax was suitable as absorbent in UV area