The solar chromosphere and the lower transition region are believed to play a crucial role in the heating of the solar corona. Models that describe the chromosphere (and the lower transition region), accounting for its highly dynamic and structured character are, so far, found to be lacking. This is partly due to the breakdown of complete frequency redistribution (CRD) in the chromospheric layers and also because of the difficulty in obtaining complete sets of observations that adequately constrain the solar atmosphere at all relevant heights. We aim to obtain semi-empirical model atmospheres that reproduce the features of the MgII H & K line profiles that sample the middle chromosphere with focus on a sunspot. We used spectropolarimetric observations of the CaII 8542{AA} spectra obtained with the Swedish 1-m Solar Telescope and used NICOLE inversions to obtain semi-empirical model atmospheres for different features in and around a sunspot. These were used to synthesize MgII H & K spectra using the RH1.5D code, which we compared with observations taken with the Interface Region Imaging Spectrograph (IRIS). Comparison of the synthetic profiles with IRIS observations reveals that there are several areas, especially in the penumbra of the sunspot, where most of the observed MgII H & K profiles are very well reproduced. In addition, we find that supersonic hot downflows, present in our collection of models in the umbra, lead to synthetic profiles that agree well with the IRIS MgII H & K profiles, with the exception of the line core. We put forward and make available four semi-empirical model atmospheres. Two for the penumbra, reflecting the range of temperatures obtained for the chromosphere, one for umbral flashes, and a model representative of the quiet surroundings of a sunspot. These are available in electronic as well as in table formats.