You need to send a network message to the server, saying which button in which block got pressed.
https://docs.minecraftforge.net/en/latest/networking/
There is no real standard for this, you will need to look at other mods if you want example code, e.g.
https://github.com/search?q=repo%3Amekanism%2FMekanism+PacketGuiButtonPress&type=code