Skip to content

mas-cli/mas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2,805 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

current release version supported OS: macOS 13+ license: MIT language: Swift 6.2 build, test & lint status dependencies status

mas

mas is a command-line interface for the Mac App Store designed for scripting & automation.

Installation

Provider Method mas macOS
Homebrew Core brew install mas Latest 14+ (recommended)
Homebrew Tap brew install mas-cli/tap/mas Latest 13+
MacPorts sudo port install mas Latest 13+
GitHub Releases Installers & source archives Any Release-dependent

Commands

Detailed documentation is available via man mas & mas --help.

Command Functionality Requires
search <term>… Search for App Store apps by name
lookup <id>… Output App Store app details
info <id>… lookup alias
list [<id>…] Output installed apps spotlight
outdated [<id>…] Output outdated apps spotlight, account for --accurate
get <id>… Get free apps, install any apps spotlight, root, account for get
purchase <id>… get alias spotlight, root, account for get
install <id>… Install already gotten or purchased apps spotlight, root, account
lucky <term>… Install first app from search <term>… spotlight, root, account
update [<id>…] Update outdated apps spotlight, root, account
upgrade [<id>…] update alias spotlight, root, account
uninstall (<id>…|--all) Uninstall apps spotlight, root
signout Sign out Apple Account from App Store
open [<id>] Open app App Store page
home <id>… Open app web pages
seller <id>… Open seller app web pages
vendor <id>… seller alias
reset Reset App Store processes
config Output config
version Output version

Integrations

Tool Functionality
Homebrew Bundle Include installed apps in Brewfile; get, install & update Brewfile apps
Topgrade Update apps

Known Issues

Issue Solution
Manage system software (macOS, Safari…) Use softwareupdate
App info inconsistencies Wait hours – days (App Store uses eventual consistency)
Cannot purchase paid apps Purchase paid apps directly in App Store; submit PR
iOS & iPadOS apps unsupported Submit PR
Hangs Index apps in Spotlight; open bug report if hangs persist
Undetected installed apps Index apps in Spotlight
This redownload is not available for this Apple Account… error Sign in correct Apple Account to App Store, or uninstall app & get it with current Apple Account
Other bugs Subscribe to existing, or open new, bug report

Development

Action Command
Build Scripts/build or Xcode 26+
Test (Swift Testing) Scripts/test

App IDs

App Store apps each have 2 unique IDs:

Type Format Example (for Xcode)
ADAM ID Integer 497799835
Bundle ID String com.apple.dt.Xcode

mas commands accept both types of app IDs as arguments.

By default, all-digit app IDs are considered ADAM IDs; other app IDs are considered bundle IDs.

--bundle forces all-digit app IDs to also be considered bundle IDs.

ADAM IDs can be found via:

  1. mas search <term>…
  2. mas list
  3. The App Store:
    1. Open an app's App Store page
    2. Open the page's Share Sheet
    3. Choose Copy
    4. Extract the ADAM ID from the URL in the copied text

Spotlight

list, outdated, get, install, lucky, update & uninstall obtain data for installed apps from the Spotlight Metadata Service (MDS).

Spotlight indexing thus must be enabled & valid for folders containing App Store apps.

Check if an app is properly indexed in Spotlight via:

## General format:
$ mdls -rn kMDItemAppStoreAdamID <path-to-app>
## Outputs the ADAM ID if the app is indexed
## Outputs nothing if the app is not indexed

## Example:
$ mdls -rn kMDItemAppStoreAdamID /Applications/Xcode.app
497799835

If an app is indexed in Spotlight, find the path to the app from its ADAM ID via:

mdfind 'kMDItemAppStoreAdamID = <adam-id>'

If any App Store apps are not properly indexed, index via:

# Individual app (if the omitted apps are known). e.g., for Xcode:
mdimport /Applications/Xcode.app

# All apps:
vol="$(/usr/libexec/PlistBuddy -c "Print :PreferredVolume:name" ~/Library/Preferences/com.apple.appstored.plist 2>/dev/null)"
mdimport /Applications ${vol:+"/Volumes/${vol}/Applications"}

# All volumes:
sudo mdutil -Eai on

Root Privileges

get, install, lucky, update & uninstall require root privileges.

If run without root privileges, mas requests them as necessary.

mas uses existing valid sudo credentials, falling back to prompting for the macOS user password, which is piped directly to a sudo process; the password is never visible to, nor stored by, mas.

Any sudo credentials used or established by mas remain valid after mas finishes, pursuant to the user-configured sudo timeout.

Apple Account Signed in to App Store

get, install, lucky, update & outdated --accurate require an Apple Account signed in to the App Store.

Apple Account Signed in to App Store for get

get requires an Apple Account signed in to the App Store.

Depending on the Apple Account settings, the Apple Account might need to be authenticated in the App Store for each gotten app, even if the Apple Account is already signed in to the App Store.

If System Settings > Touch ID & Password > Use Touch ID for purchases in iTunes Store, App Store and Apple Books is enabled, then you must authenticate (either via Touch ID or via the Apple Account password) for each previously ungotten app that is being gotten.

If that setting is disabled, then if System Settings > Apple Account > Media & Purchases > Free Downloads is set to Always Require, then you must authenticate via the Apple Account password for each previously ungotten app that is being gotten.

License

Licensed under the MIT license.

Originally created by Andrew Naylor (@argon on GitHub | @argon on X).