McDonald adds depth all over the infield and gives AL East-leading Boston an experienced glove for the stretch drive. Because the move was made by the end of August, McDonald is eligible to play for Red Sox in the postseason.
The Phillies received minor league right-hander Nefi Ogando in the deal.
The 38-year-old McDonald has spent 15 years in the majors. He has played for Pittsburgh, Cleveland and Philadelphia this season, hitting .098 with a homer and four RBIs in 61 at-bats and 45 games.
He hit .174 in 21 games with the Phillies.
''Sometimes things don't work out,'' McDonald said after Philadelphia's 4-3 loss at the Chicago Cubs on Saturday. ''I've made my way East on every team. I don't know if this is baseball's way of telling something.
''Obviously, I wish things had gone better this year. I wish I had swung the bat better. I can't put my finger on why it hasn't happened. In baseball, when you get the opportunity, you have to take advantage of it.''
The 24-year-old Ogando was 2-3 with a 4.09 ERA and three saves for Class-A Salem this season. He made 33 relief appearances covering 55 innings.
The Phillies also sent cash to Boston as part of the deal.