Skip to content
MAMP PRO Documentation

Automate MAMP PRO with AppleScript

MAMP PRO supports AppleScript and JavaScript for Automation (JXA). Both scripting languages give you access to the same set of commands. The examples below use AppleScript; see JavaScript for Automation for the JXA equivalents.

tell application "MAMP PRO"    server status "Apache"end tell

Returns one of: stopped, starting, stopping, restarting, running, activatingSystemStart, deactivatingSystemStart, killing, unknown.

tell application "MAMP PRO"    start server "Apache"    start server "MySQL"end tell
tell application "MAMP PRO"    stop server "Apache"end tell

Returns the server name on success, or missing value on error. Common reasons for failure: the server is already running, or the name does not match exactly. Use server status to check the current state before calling start server or stop server.

tell application "MAMP PRO"    start all serversend tell
tell application "MAMP PRO"    stop all serversend tell

Starts only the servers that have Start with GroupStart enabled in MAMP PRO settings.

tell application "MAMP PRO"    start groupstart serversend tell
tell application "MAMP PRO"    list all hostsend tell

Returns a list of all site names. Use list active hosts to get only sites that are available when all GroupStart servers are running, or list inactive hosts for the rest.

tell application "MAMP PRO"    add host "myproject.local" document root "/Users/me/Sites/myproject"end tell

Optional parameters:

ParameterTypeDescription
site roottextPath to the site root folder
sslbooleanEnable SSL
databasetextName of a new database to create and map to this site
install WordPressbooleanInstall WordPress automatically
wpAdminNametextWordPress admin username
wpAdminPasswordtextWordPress admin password
wpDatabaseNametextWordPress database name
wpDbUserNametextWordPress database user
wpDbPasswordtextWordPress database password
wpEmailAddresstextWordPress admin email address
tell application "MAMP PRO"    add host "myblog.local" ¬        document root "/Users/me/Sites/myblog" ¬        install WordPress true ¬        wpAdminName "admin" ¬        wpAdminPassword "secret" ¬        wpDatabaseName "myblog_db" ¬        wpDbUserName "root" ¬        wpDbPassword "root" ¬        wpEmailAddress "me@example.com"end tell
tell application "MAMP PRO"    list databasesend tell

Returns a list of all MySQL database names. System databases (information_schema, mysql, performance_schema, sys) are omitted.

tell application "MAMP PRO"    add database "my_new_database"end tell

Returns true if the database was created, false otherwise.

tell application "MAMP PRO"    create snapshot of host "myproject.local"end tell

To save the snapshot to a specific path:

tell application "MAMP PRO"    create snapshot of host "myproject.local" as "/Users/me/Backups/myproject.zip"end tell
tell application "MAMP PRO"    create snapshot of all hostsend tell

All commands are available in JXA as well. Run JXA scripts in Script Editor by selecting JavaScript as the language.

const mampPro = Application("MAMP PRO");
// Get server statusmampPro.serverStatus("Apache");
// Start and stop serversmampPro.startServer("Apache");mampPro.stopAllServers();
// List and add sitesconst sites = mampPro.listAllHosts();mampPro.addHost("myproject.local", { documentRoot: "/Users/me/Sites/myproject" });
// Databasesconst dbs = mampPro.listDatabases();mampPro.addDatabase("my_new_database");
// SnapshotsmampPro.createSnapshotOfHost("myproject.local", { as: "/Users/me/Backups/myproject.zip" });mampPro.createSnapshotOfAllHosts();

On error, JXA commands return null instead of missing value.