Abstract The aims of this study is to investigate the potential and capability of the pristine and (Sc, Ti) doped beryllium oxide nanocluster (Be12O12) to detect, and adsorb Mercaptopyridine (MCP) molecule. For this purpose, we considered different configurations for adsorbing MCP drug on the surface of Be12O12 nanocluster. All considered configurations are optimized at the cam-B3LYP/Lanl2DZ level of theory, and then from optimized structures, we selected two stable models for adsorption of MCP from S and N sites on the surface Be12O12 nanocage. The calculated results indicate that the distance between nanocluster and drug from N site (d configuration) is lower than from S site (a configuration) and adsorption of MCP from N site is more favorable than S site. The adsorption energy, Gibbs free energy, enthalpy, atom in molecule (AIM) and reduced density gradient (RDG) results reveal that the interaction of MCP with Sc and Ti-doped Be12O12 nanocage is stronger than pristine model. The gap energy of Be12O12/MCP system is in range 1.76 to 5.55 eV. Comparison results indicate that the gap energy of the d configuration of MCP drug is lower than the a configuration. The natural bond orbital (NBO), HOMO-LUMO orbitals and electrostatic potential (ESP) plots results show that the maximum positive charge is located around nanocluster surface and the most negative charge is located around adsorption position and MCP drug surface. The results of nonlinear optical (NLO) demonstrate that with doping Ti atom the dipole moment, polarizability, and first hyperpolarizability of MCP/Be12O12 complex enhance significantly from original state and the optical properties of system increase significantly from the pristine model. The calculated results confirm that Ti-doped Be12O12 nanocage is a good candidate for delivering and making sensor for MCP molecule.