If the light has a spring at the head, you can simply replace the tail end spring with the magnet, if both won’t fit, or you cant get contacts to work. Just have to make sure of good contact from cell to cap to body tube, or cell to body tube directly.
On my lights with custom 3D printed plastic tail caps I have a 2mmx6mm magnet on the cell, sitting on a metal disk(USA penny or nickel) that contacts the body tube, and a Big 4x16 or similar magnet in the tail cap behind the copper. On some I have plastic shims between metal disc and big magnet to take up play, and/or insulate the rear magnet from current.
Same can be done with aluminum caps, leave out the metal disc or stack it up to take up slack.
Care must be taken to not over compress the springs, or have too thick of stack at the tail etc, you CAN hurt drivers and crush in the end of cells.
This Can be done with no springs, but I really advise against it… half a mm difference in cells or the shims/magnets can crush things, or make the light sporadically not opperate. Usecl at least one spring if at all possible!!
Strong grade magnets , N52 if possible are a must, and thin as possible between magnetic and the outside of the cap. 1.5mm of plastic at the tail works good, but 2mm can start to interfere…
Shouldn’t matter as much with aluminum caps, they’re all pretty Thin at the back, but a cap not designed for a magnet will probably be thicker than one for it…
If at all possible putting the magnet outside the light is the best, no strength interference. But then some lower quality magnets are brittle too, depending what you do they could be chipped or shattered if dropped.
I’ll second the recommendation of kjmagnetics.com, I’ve been using them for close to 20 years( that sound wrong but probably isn’t… 15 years at least), always been quality, and good prices/ service, and selection.