Arduino Mega send data to ESP8266-01 then ESP forward to RPI (MQTT)

gfvalvo:
There aren't any magic "commands", you have to write programs (one for Mega, one for ESP) in the C / C++ language using the Arduino IDE.

Let me rephrase that. You'll certainly need to use functions like:
Serial.write()
Serial.read().
Serial.available()
Serial.parseInt()
for the task. See:

These functions handle the job of getting serial data in and out through the UART. However, just as important, you need to think about how you want to format your data before sending it from the TX and how you'll parse it after it's received on the other side. The link in my last post shows one very simple method.