Baculoviruses, the largest studied insect viruses, are highly pathogenic to host insects. Bombyx mori nucleopolyhedrovirus (BmNPV) is the main cause of nuclear polyhedrosis of silkworm, a viral disease that causes significant economic losses to the sericulture industry. The anti-BmNPV mechanism of the silkworm has not yet been characterized. Carboxypeptidase is an enzyme that is involved in virtually all life activities of animals and plants. Studies have shown that the carboxypeptidase family is related to insect immunity. There are few reports on the role of carboxypeptidase in the defense of silkworms against pathogen invasion. In this study, we identified the homologous gene Bombyx mori metal carboxypeptidases12 (BmMCP12) related to mammalian carboxypeptidase A2 (CPA2) and found that BmMCP12 had a Zn-pept domain. The BmMCP12 gene was primarily located in the cytoplasm and was highly expressed in the midgut of silkworms, and the expression level in BmN-SWU1 cells was upregulated after infection with BmNPV. After overexpression of the BmMCP12 gene, quantitative real-time (qRT)-PCR and Western blots showed that BmMCP12 could inhibit BmNPV replication, whereas knockout of the gene had the opposite effect. In addition, we constructed transgenic silkworm strains with a knockout of BmMCP12, and the transgenic strains had reduced resistance to BmNPV. These findings deepen the functional study of silkworm carboxypeptidase and provide a new target for BmNPV disease prevention in silkworms.