Two types of robust Mach–Zehnder interferometer (MZI) sensors based on microcavity in a single mode optical fibers (SMFs) are proposed, which are fabricated by femtosecond laser inscription and chemical etching. The SMFs are modified by an improved point-by-point inscription method (called a transversal-scanning method) or a line-by-line scanning inscription method, which lead to form a rectangular-shaped or a V-shaped MZI after etching. The MZIs show high refractive index (RI) sensitivity above $10^{\mathrm { {5}}}$ nm/RIU with good linearity. Especially, the rectangular-shaped MZI exhibits a ultra-high RI sensitivity of −17503.73 nm/RIU with a linearity of 0.999 in the range of 1.3371–1.3407. The results of which are coincident with theoretical calculation. In addition, the MZI structures have good mechanical strength and temperature sensitivities in water are also studied.