We consider a nonlinear microcavity separating a waveguide channel into two parts so as the coupling between them is possible only due to the resonant properties of the microcavity. We provide a rigorous derivation of the equations used in the phenomenological coupled mode theory for such systems. This allows us to find the explicit formulas for all fitting parameters such as decay rates, coupling coefficients and characteristic intensities in terms of the mode profiles. The advantages of using the semi-analytical approach are discussed, and the accuracy of the results is compared with the strictly numerical methods. A particular attention is paid to multilayered structures since they represent the simplest realization of on-channel microcavities.