For maximum possible cantrips, you take Mage Initiate and Spell Sniper, 4 levels in warlock, 1 level sorcerer, 1 cleric (Arcana), 2 druid (circle of the land), 1 wizard, 1 bard, 4 levels in eldritch knight fighter and 4 levels in arcane trickster rogue. Also, you can get one extra cantrip from racial bonuses form genasi, high elves and tieflings. It's horribly sub-optimal, but it gives you 29 cantrips in total. Also, you can get one extra cantrip from racial bonuses form genasi, high elves and tieflings.