I've done a lot of thinking on this, and half-assed a mod of them myself (which failed). I think the best way would be to have them domestic with a very long life and a low or no grazer score. They are large, slow, and made of solid stone, understandably hard to kill, but also produce materials at a very slow rate. Certain ones would go faster, like granite might produce a boulder every month or every week, to let you build a fortress in a realistic timespan, though any ore crabs would produce 1 per season or 1 per year, depending on the exact ore. Gem crabs would have a similarly slow production, with the "good" gems produced 1-2 annually, and "junk" gems produced at double rate.
To me, it would be a safe and infinite source of materials, but with a very slow rate of production. Common stone crabs and certain ores would be domestic, while most gems and good metals were wild, occurring in the caverns or extremely rarely on the surface. Candy crabs and certain others would be in the magma sea, making them extremely difficult to obtain due to their tendency to run away.
Due to their slow speed they make poor war beasts, although their sheer size and the fact that their skin is made of skin or metal, makes them very difficult to kill. You might have luck tossing a candy crab outside to face a siege, and it may route them in order, but that's a big risk.
I'm now also debating vermin. Gembugs that drop low-value gemstones could be very fun.