Psilocybin-containing mushrooms instantly develop a blue hue when the myceliem is injured or as they age. For decades, this iconic  phenomenon has intrigued  chemists and amateur mycologists alike. Oligomerization converts the Ltryptophan-derived indole nuclues into a blue chromophore.
From a chemical perspective, psilocybin may be viewed as the stabilized form of psilocin with  a phosphate ester as a protecting group, which is readily removed when mycelium is injured and psilocybin is exposed to intrinsic or animal phosphatases, followed by subsequent oligomerization.
The blueing reaction of magic mushrooms. Left: Intact mature carpohore of Psilocybe cubensis; Right: Carpophore about one minute after injury with a blade. Source from Wiley-VCH.