I believe the electric sunroof should be an annual service item. Clean, and use MB 'special grease'
With my w203, I neglected it for 3 years, and stopped using it for another year or so because I was worried about it sticking open. It was getting slower and slower, and would often move a small amount and then stop. I didn't want to push it until the clicking started, which would indicate something breaking probably.
I then decided to sort it. Found an extract from a MB service manual online for the job. Used a very liberal spray application silicone lube in a can (a bit like WD40), which seemed to get it moving a bit. Kept spraying up and down the rails, cleaning and moving and exposing more and more. Cleaned everything I could get to, including popping up the service bits on the rails. Cleaned all existing grease off.
Finally, having wiped it down mostly dry, I used a white silicone grease (available off the bay of dreams for about a fiver), which I read at the time was probably pretty close to the MB special grease.
Just wiped down the rails with a clean cloth and reapplied clean silicone grease every year until I sold it. Never had a problem after that and it work like new.
Good luck.