Have you seen https://github.com/CATIA-Systems/FMPy?tab=readme-ov-file#advanced-usage ?
In particular, https://github.com/CATIA-Systems/FMPy/blob/main/fmpy/examples/custom_input.py