A 10 speed cassette is the same width (as near as dammit) as a 9 speed one, so no worries on the mech reaching both ends of the cassette.
It’s all to do with cable pull ratios – road 10 speed pulls cable in the same ratio as 9 speed mtb, it just pulls less of it per click. So it works great with road 10 speed and mtb 9 speed mechs.
MTB rear mechs have a different pull ratio (i.e. move a different amount with that cable pull above) so wont work.
Anyway, what you’re suggesting will work fine, and is exactly what I do with my CX/winter road bike – 11-32 mtb xt cassette, deore mtb 9 speed rear mech to work with the 11-32 (or more!), 105 10 speed shifters. Then for road duty, the cassette gets swapped for a 12-28 road one.