The Mechanical Mouse will be released when you try to get Merlin the Mechanical Owl to be your friend.
How to Get the Mechanical Mouse
Go to the left of the Castle and then enter the door by the staircase. There is a robot mouse on the ground and a very unhappy girl here. Go to your backpack and use the moldy cheese. The robot mouse will go for the cheese and then you will capture him.