Open source · Tools for agents

macos-cli

One signed Swift binary that gives a script or an AI agent the Mac's own apps from the terminal, and tells it plainly what it is allowed to touch.

What it does

I wanted my agents to read my calendar, find a contact or a mail, and look at the screen without a server running beside them or a pile of AppleScript I'd have to keep alive. macos-cli is the command for that: macos <area> <action> for Calendar, Contacts, Mail, Messages, Notes, Reminders, Safari, Photos, Music, files, windows, screenshots, OCR and the accessibility tree, where a button is clicked by its name instead of its coordinates. Every command that returns data takes --json, and under --json a failure is JSON too: one object with a stable error code, a message, a hint and an exit code an agent can branch on (64 usage, 3 not found, 4 not allowed, 5 no answer in time, 6 the app reported an error). It talks to the Mac's own frameworks. There is no daemon and no MCP server: an agent runs it the way you would, as a subprocess.

How the permissions work

macOS guards most of this behind privacy permissions, and I didn't want an agent guessing at them. macos doctor --for-agent answers in JSON, without triggering a single prompt: every area the binary may need (Calendars, Reminders, Contacts, Full Disk Access, Accessibility, Screen Recording, Location, and Automation for each app it drives), its state, the command a person runs to grant it, the binary's own signature, and whether anyone is at a terminal.

Granting stays with the person. macos authorize calendars shows the system prompt, or opens the right settings pane when macOS won't prompt again; a person clicks Allow, the agent can't. A command never waits on a prompt nobody can see: when no one is at a terminal, an undecided Calendars, Reminders or Contacts permission fails at once with access_denied and the command to run.

On top of macOS there is a policy of my own, ~/.config/macos-cli/auth.json, that turns capabilities on and off. Turning one off is a single command. Turning one on asks for a confirmation typed on the terminal itself, read from /dev/tty, so piped input can't answer it; without a terminal it refuses with person_required and the policy stays as it was. The agent the policy restricts can't lift it.

What changed in 0.9.0

The full list is in the changelog.

Install

On macOS 13 or later, on Apple silicon:

brew install manuaudio/tap/macos-cli

Without Homebrew, the README has a one-line installer that checks the release's checksum and signature before it puts the binary in ~/.local/bin. Then macos doctor shows what is granted and what isn't.

For an agent, the repo carries a SKILL.md that teaches it the tool: check permissions first, then every command, which ones write, the error envelope and the exit codes. Claude Code, Codex, Cursor and the other agents skills.sh knows add it with one line:

npx skills add manuaudio/macos-cli

An agent's three calls

A terminal recording: macos doctor --for-agent piped through jq shows ready and the missing permissions, then macos calendar events --json for a calendar that does not exist, answered with a JSON error, then macos contacts search --json for a demo contact.

Recorded in a terminal on demo data: the permission check, a calendar read and a contact search, each answered in JSON.

The code

github.com/manuaudio/macos-cli

MIT licensed. Issues are open on GitHub.