A device configured for assembling a capsule containing an anhydrous material for the production of a beverage starting from a cup-shaped body open at the top and from a membrane configured to superiorly close said cup-shaped body; said cup-shaped body having an axis of symmetry and comprising an annular flange extending radially from an upper axial end of the cup-shaped body; said flange having an upper annular surface and a lower annular surface; said membrane comprising an annular peripheral portion protruding radially from said flange when said membrane is superimposed on said upper surface; said device comprising a tubular body having a longitudinal axis, internally defining a guide channel coaxial to said longitudinal axis and configured to be engaged by said cup-shaped body; said channel being provided with a shoulder transversal to said longitudinal axis extending integrally in one single piece from an inner surface of said channel towards said longitudinal axis; said device further comprising a folding assembly couplable in a releasable manner to said tubular body and comprising a first folding member and a second folding member; said first folding member being operable, when said cup-shaped body is at least partially housed inside said channel and said membrane is superimposed on said upper surface, to fold said peripheral portion with respect to said flange towards said shoulder, so as to obtain an annular flap, directed towards said shoulder; said second folding member being couplable in a releasable manner to said first folding member to axially move said flange and said flap towards said shoulder, so that said flap cooperates in contact with said shoulder and is folded towards said lower surface by means of interaction with said shoulder as the movement of said flange towards said shoulder continues, so as to obtain a substantially U-shaped fold of said peripheral portion around said flange; wherein said first folding member comprises a frustoconical wall configured to cooperate with said flange, when said cup-shaped body is at least partially housed inside said channel and said membrane is superimposed on said upper surface, to control a centring of said axis of symmetry with said longitudinal axis. said device comprising a tubular body having a longitudinal axis, internally defining a guide channel coaxial to said longitudinal axis and configured to be engaged by said cup-shaped body; said channel being provided with a shoulder transversal to said longitudinal axis extending integrally in one single piece from an inner surface of said channel towards said longitudinal axis; said device further comprising a folding assembly couplable in a releasable manner to said tubular body and comprising a first folding member and a second folding member; said first folding member being operable, when said cup-shaped body is at least partially housed inside said channel and said membrane is superimposed on said upper surface, to fold said peripheral portion with respect to said flange towards said shoulder, so as to obtain an annular flap, directed towards said shoulder; said second folding member being couplable in a releasable manner to said first folding member to axially move said flange and said flap towards said shoulder, so that said flap cooperates in contact with said shoulder and is folded towards said lower surface by means of interaction with said shoulder as the movement of said flange towards said shoulder continues, so as to obtain a substantially U-shaped fold of said peripheral portion around said flange; wherein said first folding member comprises a frustoconical wall configured to cooperate with said flange, when said cup-shaped body is at least partially housed inside said channel and said membrane is superimposed on said upper surface, to control a centring of said axis of symmetry with said longitudinal axis.