To explore an appropriate sensor for the phenytoin (PHT) drug, metal oxide nanoclusters (Zn12O12, Mg12O12, and Be12O12) were used to adsorb the PHT utilizing the density functional theory calculations. After the interaction of PHT with nanoclusters, the adsorption energies were obtained to be − 60.17, −45.57, and –32.75 kcal mol−1, respectively. Thermodynamic parameters indicated that the adsorption of PHT on the nanoclusters is exothermic and spontaneous. After the adsorption process, electrical conductivity changed to 1.18, −8.68 %, and − 26.65 % in the Zn12O12, Mg12O12, and Be12O12, respectively. Thus, the electrical conductivity values indicated that the Be12O12 nanocluster has changed after adsorption, and this change can be considered the signal for the detection of PHT. Furthermore, Be12O12 indicated an ideal recovery time for PHT desorption from the nanocluster. Solvent phase calculations indicated that the nanoclusters also could be used in biological samples. UV–vis calculation showed that after the adsorption of PHT on the Be12O12, the spectrum shifted to a higher wavelength (red shift). Thus, it can be concluded that the Be12O12 nanocluster is an appropriate candidate for PHT detection.