To MSD or not to MSD?

The createService method in the ArcGIS REST API requires services parameters wrapped in a JSON script which references a map service definition to create a service. The method has been designed this way because even in ArcGIS Server 10.1 onwards, the map service references the MSD file that is automatically created in the arcgis input directory during service publishing.

If you look at the ArcGIS Server 10.1/10.2 migration documentation then it is stated that "All map services now use the fast drawing engine that was associated with MSDs in versions 10.0 and previous. Thus, there is no distinction between MXD-based and MSD-based map services. You just open your map document in ArcMap, analyze it for performance bottlenecks, and publish it as a map service to ArcGIS Server."

This can be verified by accessing the map service editing pane in ArcGIS Server Administrator Directory. Each map service references an MSD present at:

C:\\arcgisserver\\directories\\arcgissystem\\arcgisinput\\Map_Service.MapServer\\extracted\\v101\\Map_Service.msd

Although publishing and creating a MSD directly is deprecated with 10.1, ArcGIS Server still uses a MSD which is generated automatically during the publishing process. Instead, the .sd file was introduced, which packages the data in an efficient way and is then uploaded to ArcGIS Server. Internally ArcGIS Server extracts the data in \extracted\v101 folder (an \arcgisinput directory) in the form of an MSD file, primarily due to its efficiency and drawing performance.

Further to this, there is no specific tool to create or generate a .msd in 10.1/10.2 but you can use the python script ConvertToMSD (arcpy.mapping) function to convert an .mxd to .msd.

This msd can then be used in the publishing JSON which can be wrapped around by the py script and published as a service.