A Wireless Sensor Network (WSN) is typically deployed on a place in which no electric source is provided, meaning that its battery consumption is crucial. Applications for WSNs require implementations of complex operations like network administration. To simplify the development of these applications, several mobile agent middleware solutions have been proposed (e.g., Agilla). Applications for these middleware solutions are executed by communications among agents, therefore, a common operation is to look up agents. Because existing proposals do not have much technical support for efficient approach to look up agents, every lookup consumes a significant amount of battery energy and time. In addition, current approaches can fail their lookup operations if the target agent moves during a lookup operation. This paper proposes CMSN, an efficient and effective lookup for mobile agent middleware. CMSN is inspired by CSN, a distributed hash table algorithm for WSNs. We evaluate and compare CMSN in terms of performance, effective lookups, and battery consumption.