Following the previous study [N. Wang et al., J. Phys. Chem. C 113, 7416 (2009)] which focused on specific electron transport pathway in the cyclic molecules, we investigated the chemical sensing of the metalloporphyrin-based molecular junctions. Theoretical calculations have been carried out using density functional theory combined with the nonequilibrium Green's function method. The adsorbed molecules (CO, NO, and O(2)) show diverse effects which depend on the connecting position between the metalloporphyrin with the electrodes. For iron (II) porphyrin (FeP) and manganese (II) porphyrin (MnP) connected at the 9,11-position (P-connection), the electron only passes through the porphyrin ring and the binding of ligand has no effect on the molecular conductivity. However, for the FeP and MnP connected at the 1,5-position (D-connection), the molecular conductivity decreases dramatically after adsorptions of three diatomic molecules as a result of the electron takes the path through the metallic center. For the potential application of chemical sensing, the selectivities of the FeP and MnP are discussed as well.