The trade came two days after Pirates backup shortstop Chase d'Arnaud, injured in a rundown drill earlier, had surgery for a torn ligament in his left thumb. He is expected to be sidelined six to eight weeks.
The 38-year-old McDonald hit .249 in six homers and 22 RBIs in 70 games for Arizona last season and gives the Pirates an experienced reserve for regular shortstop Clint Barmes.
McDonald, who can also play second base and third base, made only one error in 210 chances last season.
"He's a very accomplished defensive player and a veteran presence," Pirates general manager Neal Huntington said. "He brings depth and stability at a position where all of a sudden we didn't have much depth or stability."
McDonald found himself the odd man out at a crowded position. Cliff Pennington and Willie Bloomquist are expected to share the spot when the season begins, with top prospect Didi Gregorius waiting at Triple-A Reno.
McDonald has spent parts of 14 seasons in the majors with Cleveland, Detroit, Toronto and Arizona. He went to Arizona along with Aaron Hill in a trade that sent Kelly Johnson to Toronto in August 2011.
McDonald appeared in a career-high 123 games with Toronto in 2007 and batted .251. He is a .237 career hitter.
We like the defense and we like the player," Huntington said. "Secondarily, he brings experience. He's been through the battles."