AbstractAn important issue for service providers to consider before building a mobile edge services network is the limited budget for edge server deployment. In addition, the geographic position of unmanned aerial vehicle (UAV) edge server will affect its energy consumption. Therefore, we have established a UAV‐assisted mobile edge computing (MEC) system. UAV acts as a mobile edge server to provide computing services for user equipment (UE). This system aim to minimize the total energy consumption and deployment cost required for the UAVs to complete offload tasks and hover. To optimize the total energy consumption and deployment cost of UAVs, we proposed an improved mean shift (IMS) algorithm, which jointly optimizing the location and number of UAV edge servers. Various simulation results show the effectiveness of our proposed scheme in reducing energy consumption compared to other deployment methods. Furthermore, our research is of great significance for service providers in control the trade‐off between investment cost and energy consumption.