I haven’t used Logic in many years, but surely it must be capable of recording MIDI CC messages in real-time (the MD could be used as the source) and drawing in automation data.