Ryan Saxe did exactly this a number of years ago: https://github.com/RyanSaxe/mtg