A gadget? Uh, that's a really tough question.
I see a lot of people mention the pump, but for me it is part of the mandatory equipment for long MTB rides, along with some mini multi tools and a spare tire.
I think the only accessory that has survived on all my bikes for over ten years is the most basic MarshGuard mud guard :) The first thing I install on a new bike is a mud guard and I try to replace it as soon as it gets damaged. The MarshGard models proved to be the best for me, although I suppose a piece of cardboard does a similar job ;)
Among the very good accessories there is the Quad lock phone holder. I have their mounts on all my bikes and they do the job very well.
For a while I used Garmin cycle computers, but 5-6 years ago I switched to Garmin watches, which deserve an absolute recommendation because they offer everything that cycle computers offer and a little more.
A mud guard indeed seems like an indispensable tool for a mountainbiker.
I drive my road bike all year round for commuting and I also have a dismountable mountainbike mud guard.
I first had an 'ass saver', but that one is so small that my back was still full of mud.