In the present study, a pH controlled-release corrosion inhibitor system is designed based on MCM-41 as nanocontainer and 2-Mercaptobenzoxazole (MBOH) as anti-corrosion agent, which performs long-term inhibition capability in the 3 wt. % NaCl solution for the Cu and Stainless steel. The pH-sensitive composite was prepared via grafting the aminopropyl groups to surface of MCM-41 and then loading of anti-corrosion agent to modified MCM-41. XRD, FT-IR, BET, TGA, TEM, and SEM methods were used in this work to study morphological and structural properties of the nanocontainers. The loading and releasing properties of nanocontainers were studied using UV-Visible spectroscopy. The results demonstrate that the minimum releasing of MBOH occurs in neutral condition and with increasing of acidity or basicity of media, releasing rate of corrosion inhibitor from mesoporous silica increase. 2-Mercaptobenzoxazole (MBOH) was studied as a corrosion inhibitor for Cu and stainless steel in 3.5 wt.% NaCl solution using EIS and that its inhibition effectiveness increases by increasing concentration of the inhibitor The results of this approach in this paper can be used in many applications where active corrosion protection of materials is required. The results of this approach in this paper can be used in many applications where active corrosion protection of materials is required.