I'll double on this. I had an SLK230 ('03) and noticed that when at a stop light it would sometimes rev up to about 2k rpms and come back down. I started watching for it and noticed that it happened right after the rpm needle dropped into the 500 range so I think it was an anti-stall feature in the car.
a) Brake pedal is fully pressed b) Vehicle speed is at zero
If these conditions are met, and you're attempting to prevent a stall, you may want to consider pushing the transmission into neutral to prevent "unintended acceleration". Transmission is drive-by-wire, so could be done by issuing a command over CANBUS.