Chaos is important in nonlinear science and promotes the development of fundamental studies, such as neural networks, extreme event statistics, and electron transport. In this paper, a theoretical scheme for generating dynamical chaos in a Fabry-Perot cavity with two-level atoms is investigated. Through the injection of atoms, controllable chaos of the cavity and mechanical oscillator is achieved simultaneously by the external laser field. The trajectory and the maximal Lyapunov exponent that characterize the properties of the chaos could be optimized by adjusting the coupling constant, driving field, injection of atoms, the frequency of the cavity, and the frequency of the mechanical oscillator. This study provides a new idea to manipulate the cavity and mechanical chaos assisted by two level atoms. It is hoped that the results presented can benefit controllable chaos generation and its applications.