Multiphoton fluorescence microscopy is a well-established technique for deep-tissue imaging with subcellular resolution. Three-photon microscopy (3PM) when combined with long wavelength excitation was shown to allow deeper imaging than two-photon microscopy (2PM) in biological tissues, such as mouse brain, because out-of-focus background light can be further reduced due to the higher order nonlinear excitation. As was demonstrated in 2PM systems, imaging depth and resolution can be improved by aberration correction using adaptive optics (AO) techniques which are based on shaping the scanning beam using a spatial light modulator (SLM). In this way, it is possible to compensate for tissue low order aberration and to some extent, to compensate for tissue scattering. Here, we present a 3PM AO microscopy system for brain imaging. Soliton self-frequency shift is used to create a femtosecond source at 1675 nm and a microelectromechanical (MEMS) SLM serves as the wavefront shaping device. We perturb the 1020 segment SLM using a modified nonlinear version of three-point phase shifting interferometry. The nonlinearity of the fluorescence signal used for feedback ensures that the signal is increasing when the spot size decreases, allowing compensation of phase errors in an iterative optimization process without direct phase measurement. We compare the performance for different orders of nonlinear feedback, showing an exponential growth in signal improvement as the nonlinear order increases. We demonstrate the impact of the method by applying the 3PM AO system for in-vivo mouse brain imaging, showing improvement in signal at 1-mm depth inside the brain.