John McDonnell has threatened to send Jeremy Corbyn to Buckingham Palace in a taxi to tell the Queen Labour is “taking over” if Boris Johnson loses a no-confidence vote.

The shadow chancellor’s comments at Edinburgh Fringe Festival on Wednesday suggested that MPs attempting to block a no-deal Brexit would involve the monarch if they ran out of options.

Mr McDonnell said Labour would ask the Queen to appoint party leader Mr Corbyn as prime minister if Mr Johnson refused to step down.

He said he did not want to “drag the Queen into this” but would “send Jeremy Corbyn in a cab to Buckingham Palace to say we’re taking over”.

Prominent pro-EU Tory MP Dominic Grieve previously warned the prime minister that he could not ignore constitutional convention, adding that the Queen “is not a decorative extra” and may be forced to “dispense with his services herself”.

It is expected Mr Corbyn will table a motion of no confidence in the autumn to prevent a no-deal Brexit, and some senior Tory MPs have suggested they could vote against Mr Johnson’s new government as a last resort.

In a letter to The Times, former Conservative foreign secretary Sir Malcolm Rifkind said Mr Johnson could spark “the gravest constitutional crisis since the actions of Charles I led to the Civil War” if he “refused to respect the normal consequence of losing a confidence vote” and “sought to prevent both parliament and the electorate having a final say on no deal”.

Mr McDonnell’s comments came after it was revealed Mr Johnson could refuse to resign and wait a fortnight for a general election to be triggered.

Under the Fixed-term Parliaments Act 2011, MPs have 14 days to form an alternative government and win a fresh vote before a general election must be called.

A cross-party group of rebel MPs are reportedly looking into how they can prevent Mr Johnson pushing through a no-deal Brexit on 31 October, according to The Guardian.

The newspaper reports that their plan involves forcing parliament to sit through the autumn recess.