It is worth noting that a talmid chacham is allowed to sleep in shul.
The Mishna Berurah over there on the Shulchan Aruch that you cite writes:
טו) אין ישנים וכו' - ומיירי באנשים דעלמא אבל לת"ח כשלומד שם כבר ביארנו בסק"ו דשרי)
Don't sleep etc. - We are dealing with normal people, but for Torah scholars, we have already explained that it is permitted. *
So conceivably, if this attendant was a talmid chacham then it wouldn't have been a problem.
*An interesting example of this is a fascinating story related about Rabbi Yehoshua ben Levi and Eliyahu HaNavi in the Sefer Maasiyos of Rav Nissim Gaon (starting on the bottom of pg 9).
It is brought here in English and they attribute its authorship to Seder HaDoros, 'Erech R. Yehoshua ben Levi', sec. 4 (p. 192).
The story relates at some length how Rabbi Yehoshua ben Levi sought to shadow Eliyahu HaNavi so that he could learn from his ways. After eventually acceding to his request, the two go on their way. The tale (well worth the read!) talks about their travels and those they meet on their way. The pertinent part of the story plays out as follows:
Eventually, the two travelers arrived in a beautiful city; everything about the place reflected prosperity and opulence. They made their way to the shul. It was a magnificent structure, designed with elegance and taste. Everything, even the benches, was beautiful.
Rabbi Yehoshua ben Levi thought that they would have no problem receiving hospitality in such a town. But it did not work out that way. The people were not very kind. When the prayers were over, nobody approached them to ask where they planned to eat or where they planned to stay. Ultimately, they had to spend the night in the shul, sleeping on those beautiful benches, without eating supper.
This part of the story is on p.11 of sefer maasiyos:
Thus we see an early example of a talmid chacham sleeping in shul.