To address low accuracy of fruiting stem and mango detection and low efficiency of end-side deployment of real-time detection in complex orchard environments, this study reported a real-time detection algorithm for fruiting stem and mango detection with a MangoStem-YOLOv8n lightweight network model and deployed the improved model to edge devices. Firstly, the MobileNetV4 lightweight network structure was used instead of the backbone feature extraction network of YOLOv8 to reduce the model complexity. Then, the IDC (Inception Depthwise Convolution) module was fused in the MobileNetV4 network, and the MobiVari (MobileNet Variants) structure was fused in the SPPF module to improve the feature extraction capability of the model for both mango and fruiting stems. Then, the original C2f module was replaced with FasterC3 module in the neck network to improve the feature fusion ability and detection accuracy of the model. Finally, the improved model was deployed to edge devices after optimization by TensorRT. Experimental results indicated that the mean average precision of the improved model was 89.6 %, which was 1.2 % higher compared with the YOLOv8n model, the weight file size was only 4.49 MB, the number of GFLOPs of the model was 7.0 G, and the number of parameters was 2.12 M, which was reduced by 27.3 %, 13.5 %, and 29.6 %, respectively, compared with the YOLOv8n model. After the improved model is deployed to edge devices, the detection frame rate has been increased from 5.9 FPS to 15.2 FPS, significantly improving the efficiency and providing a reference for intelligent automatic mango picking technology.