mas README

The project's README from github.com/mas-cli/mas. As one markdown file: README.md.

current version supported OS: macOS 13+ license: MIT language: Swift 6.3 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 Homebrew Core 14+ (recommended)
Homebrew Tap brew install mas-cli/tap/mas Homebrew Tap 13+
MacPorts sudo port install mas MacPorts 13+
Nix Nixpkgs unstable nix-shell -p mas Nixpkgs unstable 14+
Nix Nixpkgs stable nix-shell -p mas Nixpkgs stable 14+
GitHub Releases Installers & source archives All Release-dependent

Commands

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

Command Functionality Notes Aliases
search <term>… Search for App Store apps json
lookup <id>… Output App Store app details json info
list [<id>…] Output installed apps spotlight, json
outdated [<id>…] Output outdated apps spotlight, json
outdated --accurate [<id>…] Output outdated apps spotlight, account, json
get <id>… Get free apps, install any apps spotlight, root, account purchase
install <id>… Install gotten or purchased apps spotlight, root, account
lucky <term>… Install first matching app spotlight, root, account
update [<id>…] Update outdated apps spotlight, root, account upgrade
update --accurate [<id>…] Update outdated apps spotlight, root, account upgrade
uninstall (<id>…|--all) Uninstall apps spotlight, root
signout Sign out from App Store
open [<id>] Open app App Store page
home <id>… Open app web pages
seller <id>… Open seller app web pages vendor
reset Reset App Store processes
config Output config json
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
Inconsistent app data Wait hours – days (the App Store uses eventual consistency)
Cannot purchase paid apps Purchase paid apps directly in the App Store; submit a PR
iOS & iPadOS apps are unsupported Submit a PR
Hangs Index apps in Spotlight; open a bug report if hangs persist
Undetected installed apps Index apps in Spotlight
This redownload is not available for this Apple Account… error Sign in the correct Apple Account to the App Store, or uninstall the app & get it with the current Apple Account
Other bugs Subscribe to an existing, or open a new, bug report

Development

Action Command
Build Scripts/build or Xcode 26.4+
Set up zsh wrapper Scripts/setup_libexec
Run zsh wrapper Scripts/mas
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:

JSON App Output

list, outdated & search normally output tabular data, with a few fields for each app on its own row.

lookup normally outputs fields as key-value pairs—one per line—in a contiguous block for each app, with a blank line between apps.

If --json is supplied, these commands output a stream of JSON objects—one per app—each containing all fields provided by Apple for that app.

Many of the keys provided by Apple are poorly named, so they are mapped to better names by an algorithm.

Mapped keys are sorted.

Each key should be unique within an object; if duplicate keys exist in an object, their relative ordering in the input is preserved in the output.

For tabular output, if an object contains duplicate keys, the last value is used.

If Apple renames or adds keys, suboptimal keys might be output until the mapping is updated.

JSON Config Output

config normally outputs settings as key-value pairs, one per line.

If --json is supplied, config outputs all settings in a single JSON object.

Since the keys are defined by mas, they are guaranteed to be unique & correct.

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.

App Store Apple Account Requirements

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

App Store Apple Account Requirements for get

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

Even when an Apple Account is already signed in to the App Store, the system security settings might require authenticating the Apple Account for each app being gotten.

If System Settings > Touch ID & Password > Use Touch ID for purchases in iTunes Store, App Store and Apple Books is:

Note: App Store authentication is separate from any macOS user authentication required to grant root privileges to get apps.

Outdated-App Detection

In outdated & update, the determination of whether an app is outdated is configurable via 2 settings:

Concepts & Constraints

A release is a build of an app distributed to users.

A version is a label that orders a release relative to all other releases of the same app.

The iTunes Search API reports app data only for the latest release of which it is aware; eventual consistency delays can prevent the API from knowing about the latest release available from the App Store.

Minimum macOS Check

Accuracy

The 2 outdated-app-detection modes are selectable via mutually exclusive flags:

Feature --inaccurate (default) --accurate
Method Query the iTunes Search API Initiate App Store download to read metadata
Accuracy Potential false positives or negatives No false positives or negatives
Speed Fast (~7ms per app) Slow (~175ms per app)
Requirements iTunes Search API Apple Account signed in to the App Store
Dialogs Only if --no-check-min-os Various potential dialogs
Hangs None If checking 100+ apps in quick succession

--inaccurate (default)

The inaccurate mode is optimized to:

It compares an installed app's version with the version reported by the iTunes Search API as Semantic Versions, with build metadata adjudicating ties.

This mode suffers from potential false positives & negatives:

--accurate

The accurate mode is optimized to avoid false positives & negatives at the expense of speed, potential hangs & potential dialogs.

It initiates a download of an installed app's latest release from the App Store to obtain the correct latest version from the download metadata. Subsequent behavior depends on the command:

This mode:

License

Licensed under the MIT license.

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

mas (mas-cli/mas)

Searching Database…

12.4K ·GitHub
这是什么?mas 是 Mac App Store 的命令行工具,专为脚本和自动化设计——可以在终端里直接搜索、安装、更新和卸载 App Store 应用。
这是终端工具,还是有图形界面?纯终端工具,没有图形界面。默认输出纯文本表格,但 search、lookup、list、outdated 和 config 支持 --json 参数,可以输出机器可读的 JSON 对象,包含 Apple 提供的全部字段,并改用更简洁的字段名。
需要登录 App Store 才能用吗?get、install、lucky、update 和 outdated --accurate 这些命令需要:必须有一个已登录 App Store 的 Apple 账户。默认的 outdated 检查不需要登录,而且根据你的安全设置,每次免费下载可能仍会要求 Touch ID 或 Apple 账户密码。
有什么它做不到的事吗?有——它不能管理 macOS 或 Safari 更新这类系统软件(这些请用 softwareupdate),不能购买付费应用(先在 App Store 购买,之后 mas 可以安装它们),也不支持 iOS/iPadOS 应用。
它支持哪些 macOS 版本?仅限 macOS——它面向的就是 Mac App Store。Homebrew Core 的构建要求 macOS 14 及以上(推荐);mas-cli tap 和 MacPorts 支持 13 及以上,GitHub Releases 则覆盖所有版本。
它会要求输入管理员密码吗?会改变应用状态的命令——get、install、lucky、update、uninstall——都需要 root 权限。mas 会复用仍然有效的 sudo 凭据,否则提示你输入 macOS 密码并直接传给 sudo;mas 绝不会保存密码,凭据也遵循 sudo 原本的超时规则。
为什么 mas 有时检测不到我明明装了的应用?通常是 Spotlight 的问题。mas 从 Spotlight 元数据服务获取已安装应用的信息,所以包含 App Store 应用的文件夹必须被正确建立索引——否则应用会检测不到,命令甚至可能卡住。在 Spotlight 里对这些文件夹重新建立索引即可解决。
它的过时应用检测可靠吗?默认模式查询 iTunes Search API:速度快(每个应用约 7 毫秒),但可能出现误报或漏报。加上 --accurate 参数会通过启动一次下载来读取准确的元数据——结果不会出错,但很慢(每个应用约 175 毫秒),需要登录,而且应用超过 100 个时可能卡住。
它能配合 Homebrew Bundle 和 Topgrade 使用吗?可以。Homebrew Bundle 能把你已安装的 App Store 应用写进 Brewfile,然后用 get、install 和 update 来管理它们;Topgrade 也能通过 mas 更新应用,作为整个系统更新的一部分。
Creator
mas-cli
Size
5 MB
Stars
12.4K
Age
11y
Commits · 90 Days