How to connect bluetooth magic mouse and keyboard on thunderbolt display, if they don't show up? I used a thunderbolt cable to connect my Macbook and iMac.
Pressed cmd+f2 on my iMac and the displays works perfectly.

But I cannot use my bluetooth mouse and keyboard to control the Macbook.It cannot find the mouse or any other device.


How should I pair those peripherals?
Your iMac is acts as a screen only, not as a bluetooth hub. You need to pair your devices to your main laptop only, and get a cheap keyboard for your iMac who's only purpose will be to kick it in target display mode as you described.

To re-pair Apple input devices: 

Mouse / Magic Trackpad: hold "clicked" while turning on 10- 15 seconds

BT keyboard: hold power for 15 seconds.