First-principles calculations of the magnetic anisotropy energy for Mn- and Fe-atoms on CuN/Cu(001) surface are performed making use of the torque method. The easy magnetization direction is found to be different for Mn and Fe atoms in accord with the experiment. It is shown the magnetic anisotropy has a single-ion character and mainly originates from the local magnetic moment of Mn- and Fe-atoms. The uniaxial magnetic anisotropy constants are calculated in reasonable agreement with the experiment.