An action is constructed that gives an arbitrary equation in the KdV or MKdV hierarchies as equation of motion; the second Hamiltonian structure of the KdV equation and the Hamiltonian structure of the MKdV equation appear as Poisson bracket structures derived from this action. Quantization of this theory can be carried out in two different schemes, to obtain either the quantum KdV theory of Kupershmidt and Mathieu or the quantum MKdV theory of Sasaki and Yamanaka. The latter is, for specific values of the coupling constant, related to a generalized deformation of the minimal models, and clarifies the relationship of integrable systems of KdV type and conformal field theories. As a generalization it is shown how to construct an action for the SL(3)-KdV (Boussinesq) hierarchy.