His intervention comes amid mounting pressure on Jeremy Corbyn in the wake of the historic defeat in Copeland – the first time in decades that a governing party has snatched a seat from the opposition.
Mr McDonnell put the defeat in part down to the importance of the nuclear power industry in Copeland, something which clashes with Mr Corbyn’s long-held opposition to it.
But he also cited disunity, and in particular comments made by Mr Blair and Lord Mandelson, saying: “We’ve got to unite.
“We cannot have a circumstance again, where a week before the by-election a former leader of our party attacks the party itself.”
Asked whether the by-election defeat was Mr Blair’s fault, he responded: “It’s not his fault. But I’m saying, ‘advice – please don’t do that’ and the same to Peter Mandelson. Three days before a by-election he attacked the party.”
In a speech on Brexit last week, Mr Blair said: “The debilitation of the Labour Party, is the facilitator of Brexit. I hate to say that, but it is true.”
Lord Mandelson said shortly after that “every day I try to do something to rescue the Labour Party from [Mr Corbyn’s] leadership”.
The shadow Chancellor continued: “We’ve had what, over 20 months now since Jeremy has been elected in the first leadership election, half of that time has been spent in leadership elections.
“What people are saying to me, the members of the Labour party, right across the piece, and yes, in the Parliamentary Labour Party is ‘we now need a united party’.”
Conservative Copeland candidate Trudy Harrison defeated Labour’s Gillian Troughton, a volunteer for St John Ambulance, by 2,147 votes. Labour had secured a 5,179 majority at the general election in 2015.
The increase in the Conservative vote is the biggest increase enjoyed by a government party in any by-election since 1966, and the win is the first time a governing party has taken a seat from an opposition since 1982.
Speaking to BBC Radio 4’s Today programme Mr McDonnell denied Mr Corbyn had ever said he was thinking about quitting in private, but addressing criticism of the leader he said: “There’s mixed views on Jeremy. The issue for me is, actually, he is a different type of leader, he is the person who does listen, who is decent and honest and brings people together.
“He’s not the sort of macho leaders we’ve seen in the past and that’s why we have the disasters that we have.”
Mr Corbyn’s party did manage to see of a threat from Ukip, securing victory over the party in a second by-election on Thursday in the Stoke-on-Trent Central constituency.
But the result did not stop Labour MP John Woodcock from warning that Mr Corbyn was taking the party towards what would be a “catastrophic” defeat at the next election.
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies