scrcpy allows this using ADB.
But it is also doable via AnyDesk (and probably others too) by allowing control via the accessibility settings.
Alongside with allowing control, this would also remove the need for user consent.
If the user does not add it to the accessibility allow list, then tell them a warning every time someone wants to connect to their phone/open the app and connect into view-only for the time being/to assist the user if he can't enable it.
scrcpy allows this using ADB.
But it is also doable via AnyDesk (and probably others too) by allowing control via the accessibility settings.
Alongside with allowing control, this would also remove the need for user consent.
If the user does not add it to the accessibility allow list, then tell them a warning every time someone wants to connect to their phone/open the app and connect into view-only for the time being/to assist the user if he can't enable it.