A project I've been working on for the last year or two (read: has been sitting in a drawer in half assembled state) is a USB web cam with a manual SLR lens.
You can pick and choose which USB camera you want to use, but its lens should be removable. Some are glued in a way that it's hard to detach it from the sensor without damaging it. Avoid those.
A manual full frame (it could be APS-C lense too, it really doesn't matter) 50-100 mm prime (not zoom) lens will give you exceptional magnification and working distance. Nothing I've seen on the market comes even close to the Canon 100 mm Macro lens regarding magnification capabilities and focus distance. Unfortunately, it's not manual so it's tricky to adjust aperture. The manual lens l have is, IIRC, 85 mm which is a bit less flexible in terms of focus range, but still more than serviceable (the Canon one has unusually large focus range).
I've also tried zoom lenses, but the ones I've tried had much narrower focus range and were less suitable.
The downside is the USB connection on the web cam I have, which has a bit of a lag. Also the image quality is not as crisp as you can get, but the camera was only about $30, so what could you expect, right?