Mobile agent (MA) is a popular approach that can be applied to achieve predefined goal. A ubiquitous computing engages many computational devices and systems simultaneously, and may not necessarily even be aware that they are doing so. The context of MA, including traveling path and manipulation method, may be dynamically changed according to current state of environment. Therefore, a flexible framework that can handle various MAs for a variety of applications in a ubiquitous environment is necessary. In this paper, we present an integrated and flexible framework that can adopt various applications in which the functionality of mobile agent is distinguishable in diversity of networks or systems. We also implement an agent-based platform that can guide various MAs that are initiated by mobile devices to complete their goal. In addition, we also conduct two experiments to evaluate the performance of MAG system. The evaluation result shows that the latency is reasonable and acceptable.