Efficient Mg2+/Li+ separation is highly demanded to address the global lithium scarcity. The nanofiltration (NF) membrane prepared with PEI-based monomer possess positively charged surface, exhibiting promise potential in lithium extraction from salt lake brines. In this work, water-soluble metal phthalocyanine (PEI@CoPc) was synthesized via grafting reaction between PEI and the (Tetracarboxyphthalocyaninato)cobalt(Ⅱ). The light-responsive NF membrane was prepared via interfacial polymerization technique using the water-soluble PEI@CoPc as aqueous phase monomer alone. This strategic modification significantly enhances the water permeance and Mg2+/Li+ selectivity of the membrane. The best-performing of PEI@CoPc-TMC/PES membrane shows a water permeance of 16.7 L m-2h−1 bar−1 and a Mg2+/Li+ selectivity of 29.5. The membranes exhibited exceptional selectivity towards magnesium ions while maintaining high lithium permeability, offering effective technical support for the efficient extraction of lithium resources from salt-lake brines. Moreover, the distinctive photocatalytic activity of PEI@CoPc can generate active oxidizing species such as superoxide radicals (•O2–) to oxidatively degrade pollutants, conferring the membrane excellent self-cleaning capability. The results indicated that the prepared composite membrane exhibit excellent fouling resistance and self-cleaning performance.