The Staff of the Magi allows you to absorb spells cast at you to replenish its charges.
Considering that the description doesn't say that it has to be cast by a hostile person, is it possible for, say, a mage in your group to just throw a bunch of high-level spells to charge the Staff almost to full?
It would be just before the group is about to take a long rest, in case the Staff of the Magi has pretty much exhausted everything in the last big fight.