We present a microscopic theory for the current through a tunnel Josephson junction coupled to a non-linear environment, which consists of an Andreev two-level system coupled to a harmonic oscillator. It models a recent experiment [Bretheau, Girit, Pothier, Esteve, and Urbina, Nature (London) 499, 312 (2013)] on photon spectroscopy of Andreev bound states in a superconducting atomic-size contact. We find the eigenenergies and eigenstates of the environment and derive the current through the junction due to inelastic Cooper pair tunneling. The current-voltage characteristic reveals the transitions between the Andreev bound states, the excitation of the harmonic mode that hybridizes with the Andreev bound states, as well as multi-photon processes. The calculated spectra are in fair agreement with the experimental data.