We investigate the effect of the capping layer on the thermal tolerance of magnetic tunnel junctions (MTJs) with free layer of MgO/CoFeB/spacer layer/CoFeB/MgO/capping layers (CoFeB, Ru, or Ta). We observe the largest perpendicular magnetic anisotropy energy density for the free layer with CoFeB capping layer using Ta spacer after annealing at 400°C for 1 h. Energy-dispersive X-ray (EDX) line analysis along film normal direction reveals the absorption of oxygen in MgO by Ta in the stack with Ta capping layer and Ru diffusion into CoFeB free layer in the stack with Ru capping layer, which could cause the reduction of perpendicular magnetic anisotropy. We also evaluate annealing temperature dependence of magnetic properties for the MTJ stacks with different spacer layer. We again observe the largest perpendicular magnetic anisotropy energy density for the MTJ stack using the CoFeB capping layer. The present study reveals that CoFeB capping layer is effective for achieving improved robustness against annealing.