Embedding context-aware self-adaptation mechanisms in pervasive systems is key to improve their acceptance by the users. These mechanisms involve a precise denition of the software structures that enable adding, removing or replacing components of the system to perform the adaptations. Typically the denition of these mechanisms is a complex and time consuming task. This paper presents a model-driven engineering approach to generate these context-aware self-adaptation mechanisms. The use of models transformations to dene these mechanisms helps to reduce the complexity and eort required to dene them. In order to illustrate the usefulness of the proposed approach, this paper reports its application to the development of a context-aware notication service.