This might not be the answer you are looking for, but this is one of the things you use a DAW for. If you have a project where you need to use a programming language to live generate midi, I would recommend taking a look at puredata for generating that MIDI, and a plugin host from this list[1]. You could probably use one of the programming libraries in that list for jack to write a program that uses the jack midi api directly.