I had the need to send some MIDI data to a particular device (as opposed to the usual way it works of sending data from the virtual "Keyboard Maestro" midi device.) I've compiled what I ended up with into some example macros that use some simple python scripts to accomplish this. I prioritized simplicity and getting something up and running over speed/efficiency so it is not super high-performance (and probably unsuitable for like rerouting lots of midi in real time), but if you need to just send a little midi sporadically to a specific device and want to avoid using a third-party program this may be useful. If anyone wants improve or build on this that's great of course!
Edit: Macro link in the first reply below!