My s320 1999 runs rough when the engine is cold. on 1999 Mercedes-Benz S320

When I turn on my car in the mornings for a few minutes it tries to turn off and runs rough but then after (2-5) it runs Okay.

This only happens when it is parked for like over 8 hours. It is more severe in cold weather.

I have replaced sparks, coils, and wires. Also I replaced the O2 sensor. A mechanic told me that it could be the thermostat temperature sensor. Your advise is appreciated.

Asked by for the 1999 Mercedes-Benz S320
Could be a vacuum leak, vacuum leaks can seal up as the engine gets up to operating temperature, could be a thermostatically controlled switch operating something or that the fuel mixture stays lean when cold and as the engine gets up to temperature the problem goes away. It's hard to guess without being able to do diagnostic tests first hand. These transmissions can give problems servicing them can't do harm but why were you told there was slipping?
Thanks a lot for your reply.

Actually, I got the dealer to diagnose the vehicle and they told me the AMF meter is bad, which I replaced, then I found also that the ignition coils were bad as well. I replaced the AMF meter and all three coils together and since then it runs like a charm.