The Fifth Generation (5G) mobile network will revolutionize the way of communication by supporting new innovative applications that require low latency and high data rates in smart city environments. In order to meet these applications' requirements, Ultra-Dense Network (UDN) is considered as one of the promising technological enablers in 5G. 5G UDN deployments are envisaged to be heterogeneous and dense, mainly through the provisioning of small cells such as picocells and femtocells, from different Radio Access Technologies (RATs). Nevertheless, various studies have reported that the densification is not always beneficial to the network performance. As the network density increases, this will pose further requirements and complexity of determining which RAT a user should connect with at a given time. Hence, an efficient RAT selection mechanism to choose the best Radio Access Technology among multiple available ones is a must. This paper proposes a new Context-aware Radio Access Technology (CRAT) selection mechanism that examines the context of the user and the networks in choosing the appropriate RAT to serve. A simplified conceptual model of the Context-aware RAT selection is introduced. Then, a mathematical model of CRAT considering the user and network context is derived, adopting Analytical Hierarchical Process (AHP) for weighting the importance of the selection criteria and TOPSIS for ranking the available RATs. The proposed CRAT was implemented and validated in NS3 simulation environment. The performance of the proposed mechanism was tested using two different scenarios within a smart city environment, called a shopping mall and urban city scenarios. The obtained results showed that CRAT outperforms the conventional approach namely A2A4 of RAT selection in terms of the number of handovers, average network delay, throughput, and packet delivery ratio.