Mebendazole works by inhibiting the uptake of glucose by parasitic worms, essentially starving them. This leads to the death of the worms, which are then expelled from the body through feces. The mechanism of action makes it ideal for treating different types of worm infections in children.