Mage Slayer: When a creature within 5 feet of you casts a spell, you can use your reaction to make a melee weapon attack against that creature.
If a creature within 5 feet you casts a cantrip, can the reaction attack be used?
Yes, because cantrips are spells, per 5e SRD - Spellcasting:
A cantrip is a spell that can be cast at will, without using a spell slot and without being prepared in advance. Repeated practice has fixed the spell in the caster’s mind and infused the caster with the magic needed to produce the effect over and over. A cantrip’s spell level is 0.
You only need to ask, "has the creature cast a spell?"
If you answer yes, you can use your reaction to make a melee weapon attack against that creature.
If the wording specified a spell of level one or higher, then cantrips would not trigger the reaction.