Not sure what could have been done for the American Ambassador, since it seems he put most of his faith in the new Libyan state, was not on actual Embassy grounds, merely a consulate which is essentially just an office. And the situation in Libya is still in flux, and it's looking possible that Libyans who'd been loyal to Qaddafi may have infiltrated the "security forces".
As far as the U.S. Embassy in Cairo, a common sense ROE for the Marines of "Shoot whoever comes over the wall" would have sufficed.
I'm thinking that the Muslim Brotherhood, while far from pro-West/U.S., is not to blame, but that in all the uprisings, the seat of the pantsedness (to coin an adjective) that's been going on of late, they've been infiltrated by AQ, or similar groups.