I put a first MFX plug-in on my web site. It's called ScaleEnforcer and it ensures that all the notes in the selected track are in the given scale/key (you can choose among 269 scales
If a note is not in the scale, it can be either removed or fixed (ajusted to the pevious note in scale, to the next one, to the closest one, or to a random note in the scale within one octave of the orginal note). It works offline on a MIDI clip, in real-time as an insert on your track, and even on live MIDI input. I only tested it in Sonar 2.2, so any feedback on other hosts is much appreciated.
Where to get it: www.nicolasfournel.com
Then go to the MIDI section.
Nicolas