On Mac, I have found a command line tool that lets you copy files from and to, create new folders and delete files/folders. Maybe Linux too?
https://github.com/libmtp/libmtp
Homebrew install is
brew install libmtp
It installs a bunch of mtp-* commands, including mtp-sendfile, mtp-getfile, map-files, mtp-folders, mtp-filetree, mtp-delfile, etc.
You can use filenames or fileID (returned by mtp-files or mtp-filetree) in the commands. But it seems only to operate on one file at a time: no 'copy folder'.
Unlike GUI clients like AFT or OpenMTP or calibre, it does not connect persistently (why can't those clients drop connection after each operation?).
On Windows, you can use PowerShell commands to automate Explorer. I have not explored this yet.
So it's good news: automation is feasible. I'm planning to work on a Python wrapper to make it easier to implement some use cases (e.g. back up/restore notebooks).