Using the density-functional theory, we investigate the possibility of obtaining a p–n junction in transition metal–semiconductor junctions. The systems consist in metal surfaces, M = Ti(0001), Co(0001), Pd(111) or Pt(111) in proximity to the semiconductor WSe2 monolayer. The latter is doped with hydrazine (N2H4), ammonium (NH4), or tetrafuoroborate (BF4). We determine for the M-WSe2 systems the binding energy, work function of metal surfaces, the Schottky barrier energy with and without molecular doping and the spin polarization. Results show a strong binding between the metal and WSe2 which implies a stable M-WSe2 contacts. The Spin-polarization in Ti-WSe2 (35%), Co-WSe2 (37,5%), Pd-WSe2 (13%) and Pt-WSe2 (-0.2%) suggest a significant metal-to-WSe2 spin injection in M-WSe2. Localization of hydrazine or ammonium on the WSe2 in M-WSe2 (M = Pd, Pt) changes its conductivity from p to n-type. The strong binding, the finite spin-injection, the change in conductivity and the reduction in Shottky barrier, raise the potential for a molecule-based p–n junction in metal-WSe2 field-effect transistor.