You can use Plasma ContainmentAction e.g. for Context Menus on your Plasma Desktop. They will run as plugins meaning you can add and remove them after compilation. If they exist, their name will be stored in .desktop files.
To debug your Plasma ContainmentAction call
search for "plasma" and direct kDebug's output to /tmp/whatever.txt