Move server mmm logic to a service

this should probably be simplified.