I want to create a toggle key to switch between two frequently used tools.
I thought I could switch the active tool using "gimp-context-set-paint-method," but it seems that this only changes the active tool within the script and does not modify the active tool assigned to the device.
Is it impossible to achieve this functionality with Script-Fu?
You can't change the UI through scripts. The API you mention is really the equivalent of the
Paint tool drop-down in
Edit > Stroke path and
Edit > Stroke selection.
Edit > Keyboard shortcuts
Granted, you can't have a single key that switches between two tools.