An improved congestion control mechanism based on mobile agent for wireless sensor networks is proposed, which includes node-level congestion and link-level congestion control. The formers congestion information is collected and distributed by mobile agents (MA). When mobile agent travels through the networks, it can select a less-loaded neighbor node as its next hop and update the routing table according to the nodes congestion status. Minimum package of node outgoing traffic was preferentially transmitted in the link-level congestion. Simulation result shows that proposed mechanism attains high delivery ratio and throughput with reduced delay when compared with the existing technique.