A comment on my earlier post reminded me that I should publish my latest Midi code.
I've updated my code a bit in the (gasp) 3 1/2 years since I posted that original code. In the meantime, I've taken to using a client/server model. It turns out that GarageBand doesn't seem to take kindly to a midi connection appearing and disappearing often. So, the server is started once per session and keeps the midi connection alive. The client connects over a socket to the server and translates from text input to a simple protocol. The client can appear & disappear without affecting GarageBand.
As a disclaimer, this is not my prettiest code--it basically works but is not all that robust. Get the code at http://rogerandwendy.com/roger/mac/mtl-2008.05.24.tar.gz
If you use it for anything, drop me a line or a comment to let me know.