The self-adjoint matrix Sturm–Liouville operator on a finite interval with singular potential of class $$W_2^{-1}$$ and the general self-adjoint boundary conditions is studied. This operator generalizes the Sturm–Liouville operators on geometrical graphs. We investigate the inverse problem that consists in recovering the considered operator from the spectral data (eigenvalues and weight matrices). The inverse problem is reduced to a linear equation in a suitable Banach space, and a constructive algorithm for the inverse problem solution is developed. Moreover, we obtain the spectral data characterization for the studied operator. In addition, the main results are applied to the Sturm–Liouville operator on a graph of arbitrary geometrical structure.