Abstract. Embedding context-aware self-adaptation mechanisms in pervasive systems is key to improve their acceptance by the users. These mechanisms involve a precise definition of the software structures that enable adding, removing or replacing components of the system to perform the adaptations. Typically the definition 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 define these mechanisms helps to reduce the complexity and effort required to define them. In order to illustrate the usefulness of the proposed approach, this paper reports its application to the development of a context-aware notification service.