When it appears to a court of record that a person is a material witness in a criminal case pending in a court in the county and that there is a danger of the loss of testimony of the witness unless the witness furnishes bail or is committed if he or she fails to furnish bail, the court shall require the witness to be brought before the court. After giving the witness an opportunity to be heard, if it appears that the witness is a material witness and that there is a danger of the loss of his or her testimony unless the witness furnishes bail or is committed, the court may require the witness to enter into a recognizance with a surety in an amount determined by the court for the appearance of the witness at an examination or trial. If the witness fails to recognize, he or she shall be committed to jail by the court, until he or she does recognize or is discharged by order of the court.
MCL 767.35