Tuned mass damper inerter (TMDI) is becoming a well-known device for mitigating structural vibrations. However, to be effective, the inerter needs to be connected to lower stories, which can interfere with the architectural features and therefore limit its feasibility. To overcome this challenge, a rooftop tandem tuned mass damper inerter (TTMDI) device for the structural control of a well-recognized benchmark 10-story shear building is proposed, in which the mass of the conventional TMDI is divided into two variable masses that are connected to each other using a spring and dashpot. The seven TTMDI free parameters (frequency and damping ratio of the two masses connected to the roof, the frequency and damping ratio of the connected masses, and their relative mass ratio) are optimized using particle swarm optimization algorithm (PSO) by minimizing the largest singular value of story drift transfer function. To evaluate the robustness of the optimal damper, its performance is compared to two comparable tuned TMDI configurations (TMDI-9 and TMDI-8) in both frequency and time domains under 21 far- and near-field records with forward directivity (FD) and fling step (FS) for a preselected mass ratio of 1% and three different inertance ratios. The performance indices in the time domain were selected as the maximum story drifts and absolute story acceleration. Results show that the rooftop TTMDI outperforms both TMDI configurations in both frequency and time domains, and its performance is more robust in terms of not exceeding the uncontrolled responses for most of the considered earthquake records.