How to develop iPhone MDM Server?
You have the easy way and the hard way.
Easy way: OSX Lion Server ships with a "Profile Manager" section which offers the whole MDM process (with the SCEP stack). This service is made up of ruby scripts so you can peek to see how it's done.
Hard way: implement your Profile Manager (profile generation and management), implement your Push server, add the SCEP stack (and the LDAP or Active Directory if you need to) and pray for everything to works together.
I choose the easy way :)
You can use the sample python code for MDM server provided in the MDM_Protocol named server.py. To test MDM implementation on iOS devices use your iOS Enterprise developer account to get the MDM certificate. You can use IPCU to generate Enroll config profile and you need to implement SSL for your server url. For more details refer question1 and question2