Recently, the refined singleton bound over acyclic networks was extended to convolutional error-correcting network codes over cyclic networks using extended coding vectors. In this paper, it is shown that constructing an MDS code is equivalent to constructing a multicast code. This is used to develop an algorithm for constructing MDS field-based codes over acyclic networks when the sinks know the topology of the network and the network coding employed at all nodes. A lower bound is given on the size of the field required for the algorithm to be successful. Then this algorithm is extended to construct MDS convolutional error-correcting codes over cyclic networks. The complexity of the proposed algorithm is evaluated.