Australian striker McDonald, a 54th-minute replacement for Curtis Main, headed home Mustapha Carayol’s corner in the 87th minute to equalise as Boro hit back from two goals down.
Bradley Pritchard lashed home his third goal of the season after only 32 seconds to give Charlton a flying start before Rhys Williams’ own goal in the 17th minute put the visitors firmly in control.
Boro forward Marvin Emnes struck his first goal of the year in the 76th minute to set up a grandstand finish before McDonald’s late effort, but Charlton held on to stretch their unbeaten away run to seven matches.
Charlton made a lightning start and were ahead after just half a minute.
Visiting striker Ricardo Fuller went on a marauding run down the left and when he pulled the ball back across the penalty area from the by-line, Pritchard smashed the ball home with a right-footed shot, high into the roof of the net from 12 yards.
Boro responded well as striker Carayol blazed a shot just over the crossbar and then forced Charlton goalkeeper Ben Hamer into a fine save with an angled drive from 20 yards.
But the home side were sent reeling again in the 17th minute when defender Williams put the ball past his own goalkeeper Jason Steele.
Charlton forward Yann Kermorgant fired over a low cross from the right and the ball deflected off Williams into the net from six yards.
Pritchard curled another effort just wide and at the other end Adam Reach drilled in a left-footed shot from 25 yards, which Hamer did well to hold.
Emnes threw Boro a lifeline with 14 minutes left, converting Grant Leadbitter’s cross from the right high into the net from close range, before being replaced in a tactical switch by Luke Williams.
Boro then salvaged a point as McDonald headed home Carayol’s corner in the 87th minute, while there was still time for Carayol and then Danny Hollands at the other end to go close to snatching all three points.