dnd 5e – Can Primal Savagery be used as an opportunity attack with the War Caster feat?

My druid player has just taken the War Caster feat, which states (from the PHB):

When a hostile creature’s movement provokes an opportunity attack from
you, you can use your reaction to cast a spell at the creature, rather
than making an opportunity attack. The spell must have a casting time
of 1 action and must target only that creature.

In combat, she attempted to use Primal Savagery as an opportunity attack. For Primal Savagery (from XGtE):

  • Casting Time: 1 action
  • Range/Area: Self
  • Components: S
  • Duration: Instantaneous

You channel primal magic to cause your teeth or fingernails to sharpen, ready to deliver a corrosive attack. Make a melee spell attack against one creature within 5 feet of you. On a hit, the target takes 1d10 acid damage. After you make the attack, your teeth or fingernails return to normal.

I allowed it during the session because it seems to generally fit with the spirit of War Caster, but after a closer look I’m curious. War Caster needs to target the hostile creature, and Primal Savagery is technically targeting the self before delivering an attack. Right now at level 12, Primal Savagery does 3d10 on a hit without consuming a spell slot, so it’s not negligible (though not an enormous issue).

Does Primal Savagery work with War Caster as written?

(Note: This is quite similar to this question about Bigby’s Hand but I feel that the difference is that Primal Savagery can be used to only hit one target.)