The Scotland international didn't play a single game for Hull this season after suffering a back injury towards the end of last season.
McGregor joined Hull in 2013 from Besiktas and was a first-team regular for three seasons, but has fallen behind Eldin Jakupovic and David Marshall in the ranks at the KCOM Stadium.
The 34-year-old has 35 caps for his country and played in the FA Cup final and the Europa League while on Humberside.
The Scot will now be Cardiff's No.1, as they try to steer clear of the relegation zone in the Championship.