That’s an interesting question and it depends largely on the type of sea urchin. The short answer is that pincushion urchins should be quite safe, as I believe would be the long-spine Diadema urchins that striped shrimpfish associate with, whereas it’s probably best to avoid pencil urchins and club urchins. But there are a few other things to keep in mind if you’re considering keeping a sea urchin or two with seahorses.
In general, sea urchins are quite inoffensive and do a good job of controlling microalgae in the aquarium. But like all echinoderms, they require pristine water quality and specimens from your LFS must be acclimated to the aquarium very carefully over a period of several hours, preferably via drip acclimation. They will not do well in a newly established aquarium without abundant algae or one that has high nitrate levels.
I have never had occasion to keep urchins with seahorses, so I can’t speak from personal experience regarding their compatibility. But when it comes to seahorses, I think the pincushion urchins should make great tankmates, providing you can meet their dietary requirements, which means a tank with lots of algae for them to dine upon. Personally, I think the long-spine urchins (Diadema species) would also do well with seahorses, although some folks might caution against them due to the possibility that the seahorses may accidentally impale themselves on their sharp spines. I suspect that risk is highly overstated, however, and is more of an imagined danger than an actual threat. For example, seahorses in the wild are known to associate with urchins and seem to regard them as part of the substrate, commonly even using them as hitching posts.
In fact, Tom Bowling has observed all ages of H. tristis on sea urchins, from newly settled juveniles to fully-grown adults, an unusual form of commensalism never before reported for seahorses (Bowling, pers. comm.). He believes they remain with the urchins throughout their lifetime (Tom Bowling, pers. comm.). Bowling reports the seahorses actually perch amidst the spines and ride around on the sea urchins, feeding on schools of larval shrimp and other small crustaceans. In their deep-water environment, the urchins apparently provide them with shelter and a microhabitat that attracts small crustaceans and tiny fish, creating a wide range of feeding options for the seahorses (Tom Bowling, pers. comm.).
I think I would be inclined to avoid the pencil sea urchins and club or urchins when it comes to seahorses, however. They are much more carnivorous than the other urchins, which tend to be strict herbivores. Pencil urchins will feed on sessile animal life, particularly once they’ve depleted all will be available algae, and I once saw a pencil urchin capture and consume a small horseshoe crab in an aquarium. It’s conceivable that they could also pin down the tail of a seahorse and do serious damage with their bony mouthparts.
So in general, I think pincushion urchins would do well with seahorses providing you can provide them with adequate water quality and a sufficient supply of algae. The only danger I can possibly see from them would be accidentally toppling over a piece of coral or live rock and accidentally pinning a seahorse beneath it. And if you get small pincushions and ankle the corals flash Drive rock solidly in place the chances of that seem very slim. And I think long-spined sea urchins would probably be all right as well, except for the same risk of toppling things over, but some hobbyists may prefer to be perfectly safe and avoid them to eliminate all danger, however slight, of a puncture wound from their spines. And I would tend to stay away from pencil urchins and club urchins due to their carnivorous tendencies.
If you have a stable, well established aquarium with optimum water quality and you can provide the urchin(s) with plenty of algae or a suitable substitute, then I would say you could give long-spined sea urchins a try, and I am sure they would make striped shrimpfish feel much more at home.
Best wishes with all your fishes, Nigel!