Intrathecal morphine infusion is often applied to treat chronic pain related to cancer and other conditions. However, persistent pain can be caused by nerve compression because of granuloma formation. In this study, a mouse model of morphine-induced granuloma formation by intrathecal catheterization morphine infusion into the atlanto-occipital membrane of the foramen magnum was established in wild-type mice, MrgprB2 mutant (MrgprB2) mice, and in mast cell-deficient W-sash c-kit mutant (Kit) mice. Heat-related pain after surgery was performed to investigate the antipain effect of morphine. H&E staining and immunofluorescence staining of the spinal cord were applied to analyze the mechanism of granuloma formation. Morphine-induced mast cell degranulation was assessed by measuring the Ca influx and mediator release. Anaphylactoid reactions were measured after s.c. morphine infusion to the paws. Chemokine release by mast cells was determined by Human XL Cytokine Array. Experiments with wild-type, MrgprB2 mutant, and mast cell-deficient W-sash c-kit mutant mice demonstrated that morphine activated mast cells and inflammatory cell aggregation through MrgprB2 in intrathecal infusion sites. The chemokine production of human mast cells demonstrated that granuloma formation is correlated with chemokines release. In addition, morphine activated mouse primary mast cells and de novo chemokine synthesis via the MRGPRX2 in human LAD2 cells. We concluded that granuloma formation during intrathecal morphine infusion was associated with MrgprB2/X2. Reducing MRGPRX2 potentially blocks morphine-induced side effects, including granuloma formation.