For more information...
Why were you stopped? Why did the officer have to "find" the weapon on you? Was it found during a pat-down? Did he spot it some other way? Are you required to provide CCW/HCP with a DL and notify said officer that you are carrying?
Generally (imho)
The cuffing is for "officer safety" more than "your safety," but in LE speak, it means, "I'm not sure who you are, but you do have a gun that you could use to kill me. Then I'd have to shoot you as well. So, in the interest of both our safety...."
I can't speak for other officers, but if you hand me your DL and CCL/HCP/etc, I'm not going to cuff you unless you're doing something else totally crazy to make me think that you're less than all there at that moment. Some officers might be on the other end of the spectrum when it comes to guns. Or "I'm securing any weapon I come across to make sure I don't get killed" types.
I don't think you'd win the "illegally detained" argument in court. As wheelgun said, you're not free to go. Of course, you were being detained on a traffic stop, anyway, so you weren't free to go until the stop was over, regardless of the cuffs.
As to how to handle it- like you'd handle any other encounter with any LE. Relax, don't overreact. If you have a problem with any of the officer's actions, WAIT to take it up later, not on the side of the road. Unfortunately, if you have an encounter with an LEO who decides to cuff you even though everything you are doing is legal, you might not even get a "sorry for the delay." Just write a letter, call the attorney, etc if you believe your rights were violated and file a complaint. The courts tend to side with the officer if someone on the side of the road gets "up in arms" and starts arguing with the officer (especially on tape). Sorry, it might not be right, but that is how it is today.