As music buffs can tell you, Mozart loved pranks, potty humor and his pets, which included a fox terrier and a starling.

He’d probably have been tickled to see a snake wriggling around in one of his operas.

That opera is “Così fan tutte,” which recently returned to the Metropolitan Opera. For this comedy about lovers in disguise, production designer Phelim McDermott updated the action to 1950s Coney Island, complete with sword swallowers, fire breathers, contortionists — and an 8-foot-long boa constrictor named Cupcake.

She’s the second snake to grace the Met’s stage, which over the years has seen its share of donkeys, horses, sheep and dogs, though it’s stopped short of recruiting a real elephant for “Aida.” When this “Così” debuted at the Met in 2018, it boasted a boa named Rocky Balboa — “but she’d eaten a lot of mice since then,” assistant director Sara Erde tells The Post, “and was 2 feet longer and much heavier.”

And so the opera company reached out again to All Tame Animals, its go-to critter wrangler, for a replacement. The Met auditioned several snakes — don’t ask — before deciding Cupcake, a svelte 30-something-pounder, would do.

“She’s about the same size as Rocky, and completely domesticated and comfortable,” says Zoe Ziegfeld, the professional snake handler who appears at the end of Act 1 with Cupcake wrapped around her body. “She loves heat and knows people, so it’s all fine.”

Erde says the Met set aside “a few dedicated days, just with the snake” to make sure the company was comfortable having a boa in its midst.

Even so, Ziegfeld, who for the last four years has handled snakes at the real Coney Island, says that a few “large and intimidating” male members of the Met’s stage crew keep their distance from Cupcake, who has her own dressing room.

But the singers, Ziegfeld says, seem unfazed. Mezzo-soprano Serena Malfi even gives Cupcake an onstage pat.

“The skin is so soft!” Malfi marvels. “It’s kind of amazing!” The singer says that the last time she sang in “Così,” she and Rocky Balboa had only a nodding acquaintance until curiosity compelled the mezzo to reach out and touch her backstage. Now Malfi’s character and Cupcake have what Ziegfeld calls “a moment” together onstage.

And yes, Cupcake has an understudy — a female boa named Ringo — but has yet to miss a performance. That could change, Ziegfeld notes, should she start to shed, a time when many snakes prefer to be left alone.

“People always want to know if the snakes love Mozart,” Ziegfeld says. “But since snakes have no ears, it’s very hard to say.”

“Così fan tutte” will be performed March 7, 11 and 14 at the Metropolitan Opera, Lincoln Center. Tickets, $30 and up, at MetOpera.org

Ref;nypost.com