Passivating metal/silicon contacts combine low carrier recombination with low contact resistivities, enabled by a low gap state density at their interface. Such contacts find applications in high-efficiency solar cells. We perform first-principles calculations based on density functional theory to investigate the surface defect and metal-induced gap state density of silicon in close contact with metals (Al and Ag). We confirm that surface hydrogenation fully removes surface-defect gap states of (111)-oriented silicon surfaces. However, the metal-induced gap state density increases significantly when metals are closer than 0.5 nm to such surfaces. These results highlight the importance of the tunneling-film thickness in achieving effective passivating-contact formation.