Mackay rested a number of senior players and made 11 changes at Moss Rose but still saw the Championship leaders take a 57th-minute lead through Nat Jarvis.
However Matthew Barnes-Homer levelled things up for the non-league side in the 85th minute before bagging the winner from the spot with two minutes remaining.
Mackay said: "We picked a team here that we felt was capable of winning the game and I thought there were some fantastic performances.
"They got to five minutes to go and they just switched off and that lost us the game - but they will learn from that.
"I don't regret picking this team, I think they did wonderfully.
"I thought all the youngsters at the back were fantastic and Declan John has shown he has exceptional potential for Cardiff going forward.
"Both teams tried to play the ball but Stephen McPhail has that extra bit of class which really helped the youngsters.
"We have a dressing room of very disappointed players but they should be proud of the performance they put in.
"We can now get our head in the league but I want to wish Macclesfield good luck in the next round, they were fantastic."