We consider canonical systems (with $2ptimes 2p$ Hamiltonians $H(x)geq 0$), which correspond to matrix string equations. Direct and inverse problems are solved in terms of Titchmarsh--Weyl and spectral matrix functions and related $S$-nodes. Procedures for solving inverse problems are given.