Maybe all the BS talk with Clara and the doctor not being her boyfriend makes her obsessed with him later on in her life and she knew where he was and where to get the clockwork robot?
That sounds similar to a theory I heard on Monday: somehow, all the different Claras throughout history (after the events of The Name of the Doctor) are getting mashed together in some sort of afterlife after they die. Since all of them are connected to the Doctor in some way, the resulting being is obsessed with him.