I had a similar problem on my'85 500SEC.
It turned out to be a vacuum leak, under the air sensor plate.
There is a snorkel type piece that is an oval with a rubber piece that attaches to the bottom of the air plate. It cracks as it ages.
I had my injectors and the air rails along with this snorkel piece replaced and the idle smoothed out.
Good luck, John F.