Professor McGonagall is the Transfiguration teacher and Head of Gryffindor House. As such, she is Harry's immediate authority figure when he gets his repeated detentions from Professor Umbridge. When Professor Umbridge starts punishing Harry regularly, Professor McGonagall advises Harry very seriously not to push her: "Potter, use your common sense [...]. You know where she comes from, you must know to whom she is reporting" (12.305).
Professor McGonagall resents Professor Umbridge's intrusion into Hogwarts as much as Harry does, but she also recognizes that provoking Professor Umbridge is just going to make her act even more outrageously. The smart thing to do, obviously, is to lie low so as not to give Professor Umbridge an excuse to act out.
While this is superb advice from Professor McGonagall, she has almost as much trouble following it as Harry does. Underneath her stern, highly professional exterior, Professor McGonagall has a hot temper and absolute loyalty to Dumbledore. When Professor Umbridge insists on being present at Professor McGonagall's career meeting with Harry, the "meeting" winds up dissolving into a shouting match between the two professors. McGonagall tells Umbridge flat out that, "There may well be a new Minister for Magic by the time Potter is ready to join [the Aurors]!" (29.151). What is more, she shrieks, "Potter [...] I will assist you to become an Auror if it is the last thing I do! If I have to coach you nightly, I will make sure you achieve the required results!" (29.149). Clearly, Professor McGonagall is losing patience with this whole "be careful" plan that she recommended to Harry.
But Professor McGonagall's loyalty and good-heartedness really become targets for Professor Umbridge when she goes to defend Hagrid from the Aurors. Professor Umbridge tries to have Hagrid escorted away from Hogwarts by Ministry officials, since she hates half-humans and Hagrid is half-giant. The Aurors arrive in the middle of the night like cowards. Seeing Hagrid trying to resist a bunch of Dark wizard catchers on his own, Professor McGonagall marches out to protest. But she is hit by four Stunning Spells right to the chest.
Harry witnesses this fight during his Astronomy OWL exam, and the administrator of the exam, Professor Tofty, shouts, "Galloping gargoyles! [...] Not so much as a warning! Outrageous behavior!" (31.157). Of course, he's quite right that this is shocking: Professor McGonagall is an elderly lady, and four Stunners to the chest earn her a trip straight to St. Mungo's Hospital. As a result (unfortunately), she is not there to council Harry not to rush off to the Department of Mysteries and she also misses Professor Umbridge's showdown with Hermione and the centaurs in the Forbidden Forest. Shame! We're sure she would've enjoyed watching Professor Umbridge get trampled.