We report on the detection of two series of harmonically related doublets in IRC +10216. From the observed frequencies, the rotational constant of the first series is B = 1380.888 MHz and that of the second series is B = 1381.512 MHz. The two series correspond to two species with a 2Σ electronic ground state. After considering all possible candidates, and based on quantum chemical calculations, the first series is assigned to MgC3N and the second to MgC4H. For the latter species, optical spectroscopy measurements support its identification. Unlike diatomic metal-containing molecules, the line profiles of the two new molecules indicate that they are formed in the outer layers of the envelope, as occurs for MgNC and other polyatomic metal-cyanides. We also confirm the detection of MgCCH that was previously reported from the observation of two doublets. The relative abundance of MgC3N with respect to MgNC is close to one while that of MgC4H relative to MgCCH is about ten. The synthesis of these magnesium cyanides and acetylides in IRC +10216 can be explained in terms of a two-step process initiated by the radiative association of Mg+ with large cyanopolyynes and polyynes followed by the dissociative recombination of the ionic complexes.Based on observations carried out with the IRAM 30 m telescope and the Yebes 40 m telescope. IRAM is supported by INSU/CNRS (France), MPG (Germany) and IGN (Spain). The 40 m radiotelescope at Yebes Observatory is operated by the Spanish Geographic Institute (IGN, Ministerio de Fomento).