I suggest not making a homebrew spell.
Instead of having a spotlight-stealing mentor solving their problems for the player for free, instead make the PCs the real heroes of preparing their eventual dragon fight themselves and paying up for their entire preparation.
Having the Cleric and Druid prepare Prot vs Energy is a very simple thing.
The mentor could also teach the Protection from Energy Spell to the Wizard. Even better: Send the party on a mini-side quest for the Wizard to actually find the spell, and learn it, from some old book by an ancient wizard, whose wizard tower is now in ruins. Now guarded by magic puzzles and monsters, of course.
In addition to normal potion crafting cost and time, a special ingredient could be needed: each Potion of Protection from Cold needs the heart of a "powerful cold creature". So, the party goes on a short "single game session" side quest to learn that, in a high mountain pass not too far away, a pack of Winter Wolves is rumored to have terrorized that area for years, blocking the pass for use by travelers. The pack is led by an older, stronger, more cunning Winter Wolf pack leader. The party brings back enough hearts to craft the potions they need, plus a few extra.
During that little adventure they could meet with and help a "Blue Satyr", a cold-based satyr, that is willing to allow the Ranger to learn, temporarily, the Protection from Energy spell, usable once a day, by giving him a tiny magical blue sprite as a reward. "But the more you ask for its help, and the longer it has to stay with you, the more it will want to go home, and thus the harder it will be to convince it to remain with you." Basically, each time the Ranger uses the sprite (the Ranger must use his Action to use the spell-sprite), he must make a CHA Save with increasing difficulty, say initial base DC 8, +1 per previous casting, +1 per week elapsed from the beginning, until a failed the save, and then the sprite says goodbye and leaves. In other words: Ranger also gains the needed spell, but not in a long-term unbalancing "I have more known spells than I should have" fashion.
Transport to the side quest areas could also come at a cost, if they need special teleportation or other forms of fantastic transportation services.
So, players don't like to spend their gold, sure, but at level 7 they should have more than enough gold to pay for everything. If not, add another mini-adventure, this time to go get a pirate's gold chest or something with a not much magical items but a good "cash" payout. In any case, the dragon's hoard will surely more than compensate for any "war preparations" expenses needed (just adjust the final treasure).
Ding it like this has the following advantages:
- Extra game sessions, the preparation for killing the dragon is a small adventure in itself, or maybe even three.
- No need for Concentration checks when taking damage from the dragon. That kind of fight lasts long enough and you'd need repeated castings mid-fight to make the resistance last more than a couple rounds. Using potions it is a way more reliable form of protection.
- PCs become 100% proud of their potions.
- The mentor is a guide, not stealing the spotlight of the PCs' capabilities.
Heck, the mentor could even be a level 1 old wise man instead of an all powerful figure, and it would work. Personally as a player I really hate those vitally important DM-PCs around which the entire quest seems to rotate. It make me want to say : "Hey powerful mage why don't YOU go solve the problem if you think it is so important?". It makes more sense for the NPCs to help the PCs without overshadowing them.
If you feel that your NPC is too powerfully overshadowing the players, try this:
Some strong enemy attacks the powerful NPC mentor, and there is a great magical battle. With help of PCs, the mentor wins, even then he has to use a WISH (maybe by using an item because while high level, he is not level 17+), and magic too powerful so his "soul" is badly wounded, and he forever more losses ALL of his magical powers. Cue dramatic scene. So you get a high HP, high knowledge mentor, but not an NPC that risks outshining the PCs. "Now my young friends the future of the world lays even more on YOUR shoulders!"