Lets say the query is: "Key of C, 4/4, [Am7,Am7,Em7,Dm7] My first naive approach will be to try this:
1) ensure the tune time sig is a match
2) for each bar collect the pitches and ensure that they contain the chord(or any inversion) of the chord at the index in question.
3) any non-chord/passing tones must exist in the overarching key or its not a match. If all 4 bars are a match I will reconstruct a midi clip and return it as a result.