I am adopting the MLA citation style. If a book is written by a principal author with an editor, is it obligatory to add an editor of the book in citation?
There are a lot of kinds of editors, but it would be very unusual if any of them contributed to the actual intellectual content of a work. In that sense, no, it isn't necessary to cite them so some would put the name of the editor, say in parentheses, with the citation: "...(edited by x.y)".
Some editors handle the publication process, some give advice on writing style, some might even rearrange things, but few would contribute to the actual ideas. There might be rare exceptions.
There is, however, another kind of editor. Some books are little more than a compendium of the work of several authors. In this case and "editor" will have done the creative work, such as it is, of collecting those papers into a single volume. Then, if you need to cite the volume itself, cite the "editor" who created it. But the papers themselves don't need the editor's name attached.
Many books don't have editors (unless they are employees of the publisher). But some do, and it is possible you should add their name to the citation. For example if the book is a collection of papers by [famous author], then the editor is important, since they chose which papers to collect. Similarly the editor of a review volume is also important even if they didn't contribute any articles to the volume.
If the name of the editor appears on the front cover, I would default to 'yes'.