This paper investigates the potential benefits of integrating rooftop greenhouses (RTGs) with buildings to reduce energy and CO2 costs, contributing to urban decarbonization efforts. This integration not only advances sustainable urban agriculture but also aligns with the United Nations Sustainable Development Goal 7 (SDG7) - Affordable and Clean Energy, and Sustainable Development Goal 11 (SDG11) - Sustainable Cities and Communities, through its energy-efficient, low-carbon approach. We hypothesize that this integration can significantly lower energy use in integrated RTGs (i-RTGs) and set out to validate this through dynamic models for both building and i-RTG climates, focusing on CO2 concentration, humidity, and temperature. Central to our approach is the implementation of a nonlinear model predictive control (NMPC) framework, which utilizes these dynamic models to make control decisions aimed at minimizing total control costs. This framework operates in a receding horizon procedure, regulating climate factors within the i-RTG and building using various actuators. We validate our approach by simulating an i-RTG atop a building in eleven different cities, demonstrating interactions such as energy, moisture, and CO2 exchange. Significantly, our study reveals that integrating i-RTG with buildings under the NMPC framework leads to a 15.2% reduction in control costs. Additionally, we find that the i-RTG model is adaptable to different climates, with colder regions showing greater cost reduction potential. Our study underscores the viability and advantages of integrating i-RTGs with buildings, offering a sustainable, decarbonizing solution for urban agriculture and building management that contributes to the fulfillment of SDG7 and SDG11.