Using density-functional theory calculations, we investigate the dominant defects formed by boron (B) and carbon (C) impurities in a CoFe/MgO/CoFe magnetic tunnel junction (MTJ) and their influence on conductivity and tunneling magnetoresistance (TMR). We find that, in the O-poor conditions relevant to experiment, B forms the substitutional defect B Co and C forms the interstitial site C i at the CoFe/MgO interface. The C-doped MTJ is predicted to have a significantly higher TMR than the B-doped MTJ. This is due to interface state densities associated with the majority spin 1 -symmetry bands being more heavily suppressed by the B Co defects than by the C i defects. Our results indicate that carbon can serve as a viable alternative to boron as a dopant for MTJ fabrication.