In a civil lawsuit against the United States to overturn the conviction, lawyers for Mr Bergdahl said the military failed to remedy "unlawful command influence" by both the former commander in chief and late Arizona Senator.
"The scandalous meddling in a specific case by leaders of the political branches—one of whom was commander in chief of the armed forces—would never be tolerated if the proceeding had been a criminal prosecution in this or any other federal district court and should not be tolerated in a court-martial," the filing said.
Mr Bergdahl was abducted by the Taliban-affiliated Haqqani Network and held hostage for almost five years after leaving an isolated post in Afghanistan in 2009 for what he says was to report poor leadership to a higher US headquarters.
He was returned in a prisoner exchange for Taliban prisoners held at Guantanamo Bay, which drew fierce political criticism from both Mr Trump and Mr McCain in the lead up to the 2016 election.
Mr Berdahl plead guilty to desertion and misbehaviour before the enemy and was sentenced to a dishonourable discharge and $10,000 in fine.
During the court-martial throughout 2016 and 2017, then-candidate Trump called him, among other epithets, a "dirty rotten traitor".
"Before and during the 2016 presidential campaign, candidate Trump repeatedly vilified plaintiff, describing him as a traitor at numerous rallies, and suggesting, among other things, that he should be executed," the filing said.
Lawyers submitted a 28-minute supercut of Mr Trump railing on Mr Bergdahl into evidence
Meanwhile, Mr McCain - himself a prisoner of the Vietnam War, said the prisoner exchange to bring Mr Berghdal home put the lives of American serviceman at risk.
While the court-martial considered Mr Berghdal's case, the lawsuit says the Army was placed under intense pressure from Mr McCain over its decision-making process.
"Senator McCain reacted swiftly by stating, 'If it comes out that [plaintiff] has no punishment, we’re going to have to have a hearing in the Senate Armed Services Committee,' adding that plaintiff–as to whom charges had not even been referred – 'is clearly a deserter'," the filing says.
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies