We derive an expression for the angular power spectrum of cosmic microwave background anisotropies due to gravity waves generated by a stochastic magnetic field and compare the result with current observations ; we take into account the non-linear nature of the stress energy tensor of the magnetic field . For almost scale invariant spectra , the amplitude of the magnetic field at galactic scales is constrained to be of order 10 ^ { -9 } Gauss . If we assume that the magnetic field is damped below the Alfvén damping scale , we find that its amplitude at 0.1 h ^ { -1 } Mpc , B _ { \lambda } , is constrained to be B _ { \lambda } < 7.9 \times 10 ^ { -6 } e ^ { 3 n } Gauss , for n < -3 / 2 , and B _ { \lambda } < 9.5 \times 10 ^ { -8 } e ^ { 0.37 n } Gauss , for n > -3 / 2 , where n is the spectral index of the magnetic field and H _ { 0 } = 100 h km s ^ { -1 } Mpc ^ { -1 } is the Hubble constant today .