This is a simple Micro-switch filament run-out sensor built into the filament guide bracket for the MakerGear M2.
I used the old Z endstop micro-switch and LED from the M2, as I have replaced the Z endstop with an inductive probe. In order to get the LED to light up when out of filament, I de-soldered the ground side of the led from the center pin, and soldered it to the unused pin.
You will need to modify your firmware to enable the run-out sensor to trigger the M600 command, and your firmware will need to have support for it.
I currently use Marin V1.1.0 RC7. To add this, you will need to enable "#define FILAMENT_RUNOUT_SENSOR" in Configuration.H as well, the logic needs to be reversed if set up the same way the MakerGear M2 Endstops are you do this in the linee "const bool FIL_RUNOUT_INVERTING = true;"
You will need to enable; "#define FILAMENT_CHANGE_FEATURE" in Configuration_adv.H
You will also need to add a pin Definition to the Pins.H file (pins_RAMBO.h for me) (my printer is running with a RAMBo 1.3, and I used the Z max endstop connection, so the line I added to it was "#define FIL_RUNOUT_PIN 30"