@Hanoofy first of all, welcome to the forum!
So just to clarify, what do you mean by “have no way to connect to the ports from modep”? Are you trying to send a midi control code from the command line via the Python script? If MODEP recognizes your Python script as a MIDI device then you should be able to click “Assign” on any control then send a CC from your python script. MODEP will respond with a confirmation that the plugin’s control was assigned to the passed CC.
If you’re interested, I wrote an entire Python program that runs on a Raspberry Pi PICO that I embedded into a custom box to send midi CCs to MODEP: MIDIZilla for MODEP
Maybe my project might answer some of your questions.