Mesoporous silica (MCM-41) nanoparticles modified by azobenzene derivatives, capable of storing small molecules and releasing them following light irradiation, have been fabricated and characterized. In the presence of the beta-cyclodextrin and/or pyrene-modified beta-cyclodextrin rings, the beta-cyclodextrin and/or pyrene-modified beta-cyclodextrin rings will thread onto the azobenzene-containing stalks and bind to trans-azobenzene units to form the pseudorotaxanes, thus sealing the nanopores and stopping release of the cargo. Upon irradiation, the isomerization of trans-to-cis azobenzene units leads to the dissociation of the beta-cyclodextrin and/or pyrene-modified beta-cyclodextrin rings from the stalks, thus opening the gates to the nanopores and releasing the cargo.