Interesting, I did something similar using MQTT and routing the MQTT messages through my root node which had an ethernet connection alongside it. I'm working to modify my painlessmeshboost to do the forwarding for me though and may drop my ESP32 root node completely at some point.
My plan is to modify the onReceive on the Pi to capture mesh messages and if they are JSON intended for the external network, forward them via mosquitto. I am creating a new MQTT connection for painlessmeshboost which will allow me get external MQTT and send them to the mesh if they are on a specific topic. I'm not ready to share this code yet, but in theory, it will work. The nice thing about using the RPi for all of this is I don't need the extra ESP32 for the root, and it still does all the work.
Once you have this work done, sending MQTT from the local net to the mesh is simple so sending JSON based commands becomes a coding exercise. I'm building a mesh for my path lights which can't be easily connected to home wifi. I am using MQTT + JSON to turn lights on/off and control the colors. The nodes are all low cost ESP32C3, and right now, the root is an S2. Like I mentioned, I hope to make the root the RPi soon.
TLDR; Connect the RPi to the mesh and have it communicate with the local net over or USB wifi. Then use the Pi to do the MQTT forwarding, or make it the MQTT server.