Restoring MP When Hit

I'm looking to add an accessory to my game where, when whoever has the accessory equipped takes damage, they get MP restored. Does anyone know how I can do this?
I'd use two Yanfly plugins: Buffs & States Core, and Auto Passive States.

Follow the instructions to put a passive state on the accessory.

In that state, put the notetag:
Code:
<Custom Respond Effect>
if (this.isDamage())
    target.gainMp(X);
</Custom Respond Effect>

where X is how much MP to recover.
Perfect, that worked. Thanks!

Original thread: https://forums.rpgmakerweb.com/threads/restoring-mp-when-hit.156174/