Control devices, also known as protection systems, have been proposed to reduce undesirable vibrations, dissipate the input energy, and preserve the integrity of structures subjected to ground motion.The Tuned Mass Damper Inerter (TMDI) is a passive control device that integrates a classical Tuned Mass Damper (TMD) with an inerter mechanism that induces inertial resisting forces to the controlled system and consequently provides a mass equivalent amplification effect, also known as inertance, with the advantage that it demands less attached mass to achieve suitable vibration control of structures subjected to dynamic loads.This paper presents the implementation and optimal design of a TMDI on a mid-rise building in which the structural model is simplified as a two-dimensional shear frame subjected to different ground motion-induced vibrations, intending to reduce the lateral displacements of the structure.Moreover, for the tunning process of the device, the design parameters have been optimized using a natural-based metaheuristic algorithm known as the whale optimization algorithm (WOA).The objective function to be optimized is a linear combination of the maximum peak displacement and the root mean square (RMS) response for the displacement.The obtained results show remarkable reductions in the dynamic response of the structure, thus demonstrating the effectiveness of TMDI for structural control and damage reduction.