Here are two endstop holders for makerbot style mechanical endstops.
They are made to fit snuggly around a 20mm linear rails and are held tight with a single bolt.
One is flush with the rail, designed to be activated by a plate, the other is raised up further to be activated by a wheel.
There is a channel to accommodate the resistors and LED, so the endstop sits flush in the mount.
I attached the mounts to the rail using a M5x10mm screw and a T-nut
The sensors are attached by 2 M3x8mm screws
I printed with fairly high fill of 50% and a shell of 1.2mm, probably overkill adjust to your own preferences.