Modular operads relevant to string theory can be equipped with an additional structure, coming from the connected sum of surfaces. Motivated by this example, we introduce a notion of connected sum for general modular operads. We show that a connected sum induces a commutative product on the space of functions associated to the modular operad. Moreover, we combine this product with Barannikov’s non-commutative Batalin–Vilkovisky structure present on this space of functions, obtaining a Beilinson–Drinfeld algebra. Finally, we study the quantum master equation using the exponential defined using this commutative product.