{"id":50993835,"url":"https://github.com/cyanheads/macos-mcp-server","last_synced_at":"2026-06-20T06:32:35.188Z","repository":{"id":364441658,"uuid":"1248869548","full_name":"cyanheads/macos-mcp-server","owner":"cyanheads","description":"macOS system controls, window management, and hardware state for MCP clients","archived":false,"fork":false,"pushed_at":"2026-06-13T03:59:17.000Z","size":447,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-13T04:05:15.356Z","etag":null,"topics":["ai-agents","ai-tools","automation","cyanheads","jxa","macos","mcp","mcp-server","model-context-protocol","osascript","system-control","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cyanheads.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"cyanheads","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":"cyanheads","thanks_dev":null,"custom":null}},"created_at":"2026-05-25T06:05:38.000Z","updated_at":"2026-06-13T03:59:20.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/cyanheads/macos-mcp-server","commit_stats":null,"previous_names":["cyanheads/macos-mcp-server"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/cyanheads/macos-mcp-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyanheads%2Fmacos-mcp-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyanheads%2Fmacos-mcp-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyanheads%2Fmacos-mcp-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyanheads%2Fmacos-mcp-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cyanheads","download_url":"https://codeload.github.com/cyanheads/macos-mcp-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cyanheads%2Fmacos-mcp-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34560265,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-20T02:00:06.407Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-agents","ai-tools","automation","cyanheads","jxa","macos","mcp","mcp-server","model-context-protocol","osascript","system-control","typescript"],"created_at":"2026-06-20T06:32:34.390Z","updated_at":"2026-06-20T06:32:35.158Z","avatar_url":"https://github.com/cyanheads.png","language":"TypeScript","funding_links":["https://github.com/sponsors/cyanheads","https://buymeacoffee.com/cyanheads"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003e@cyanheads/macos-mcp-server\u003c/h1\u003e\n  \u003cp\u003e\u003cb\u003eControl macOS system settings, apps, windows, audio, displays, screenshots, and Focus mode via MCP. STDIO or Streamable HTTP.\u003c/b\u003e\n  \u003cdiv\u003e13 Tools • 3 Resources\u003c/div\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Version](https://img.shields.io/badge/Version-0.1.4-blue.svg?style=flat-square)](./CHANGELOG.md) [![License](https://img.shields.io/badge/License-Apache%202.0-orange.svg?style=flat-square)](./LICENSE) [![MCP SDK](https://img.shields.io/badge/MCP%20SDK-^1.29.0-green.svg?style=flat-square)](https://modelcontextprotocol.io/) [![npm](https://img.shields.io/npm/v/@cyanheads/macos-mcp-server?style=flat-square\u0026logo=npm\u0026logoColor=white)](https://www.npmjs.com/package/@cyanheads/macos-mcp-server) [![TypeScript](https://img.shields.io/badge/TypeScript-^6.0.3-3178C6.svg?style=flat-square)](https://www.typescriptlang.org/) [![Bun](https://img.shields.io/badge/Bun-\u003e=1.3.0-blueviolet.svg?style=flat-square)](https://bun.sh/)\n\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Install in Claude Desktop](https://img.shields.io/badge/Install_in-Claude_Desktop-D97757?style=for-the-badge\u0026logo=anthropic\u0026logoColor=white)](https://github.com/cyanheads/macos-mcp-server/releases/latest/download/macos-mcp-server.mcpb) [![Install in Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en/install-mcp?name=macos-mcp-server\u0026config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBjeWFuaGVhZHMvbWFjb3MtbWNwLXNlcnZlciJdfQ==) [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Server-0098FF?style=for-the-badge\u0026logo=visualstudiocode\u0026logoColor=white)](https://vscode.dev/redirect?url=vscode:mcp/install?%7B%22name%22%3A%22macos-mcp-server%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40cyanheads%2Fmacos-mcp-server%22%5D%7D)\n\n[![Framework](https://img.shields.io/badge/Built%20on-@cyanheads/mcp--ts--core-67E8F9?style=flat-square)](https://www.npmjs.com/package/@cyanheads/mcp-ts-core)\n\n\u003c/div\u003e\n\n\u003e **macOS-only.** This server controls the local macOS system — it requires the host machine to be running macOS. HTTP transport is supported for completeness, but the practical use case is stdio: run it locally and point your MCP client at it.\n\n---\n\n## Tools\n\n13 tools covering macOS system state, app and window management, audio routing, display control, screenshots, Finder integration, notifications, and Focus mode:\n\n| Tool | Description |\n|:-----|:------------|\n| `macos_get_info` | System snapshot: battery level and charging status, power source, Wi-Fi SSID, hostname, macOS version, uptime, and display count |\n| `macos_check_permissions` | Reports Accessibility, Screen Recording, Automation \u003e Finder, and Notification status for the calling process |\n| `macos_manage_apps` | List, launch, quit, force-quit, hide, or show applications |\n| `macos_manage_windows` | List, focus, move, resize, move_resize, minimize, fullscreen, or close windows |\n| `macos_control_volume` | Get or set system output volume (0–100) and mute state |\n| `macos_control_audio` | List audio devices, get current defaults, or switch the default input/output device |\n| `macos_control_appearance` | Get or set dark/light mode |\n| `macos_control_system` | Lock the screen or put the display to sleep |\n| `macos_take_screenshot` | Capture full screen, display, named app window, or pixel region; saves PNG; optional base64 JPEG preview |\n| `macos_manage_displays` | List connected displays and apply named display layout presets |\n| `macos_send_notification` | Post a notification to macOS Notification Center |\n| `macos_manage_focus` | Get or set Do Not Disturb / Focus mode |\n| `macos_manage_finder` | Frontmost path, current selection, reveal, open with app, or move to Trash |\n\n### `macos_get_info`\n\nReturns a live system snapshot with no prerequisites.\n\n- Battery level (0–100), charging state, and power source (`AC`, `Battery`, `UPS`); `null` on desktops with no battery\n- Wi-Fi connection status and SSID\n- Hostname, macOS version string (e.g. `\"15.1.0\"`), uptime in seconds\n- Connected display count\n\n---\n\n### `macos_check_permissions`\n\nReports permission status for each capability this server exercises. Run this first when debugging why a tool is failing.\n\n- **Accessibility** — required for window manipulation (`move`, `resize`, `minimize`, `fullscreen`, `close`), app hide/show\n- **Screen Recording** — required for window screenshots (`macos_take_screenshot` with `target=window`)\n- **Automation \u003e Finder** — required for `macos_manage_finder` with `action=get_selection`\n- **Notifications** — always granted (osascript notifications bypass Do Not Disturb)\n- Returns the name of the calling process (e.g. `\"ghostty\"`, `\"node\"`) so you know which process to grant permissions for\n\n---\n\n### `macos_manage_apps`\n\nManage the lifecycle of user-facing applications.\n\n- `list` — all running user-facing apps with name, bundle ID, PID, visible, and frontmost flags\n- `frontmost` — name, bundle ID, PID, and frontmost window title of the active app\n- `launch` — open or activate an app by name or bundle ID; `hidden=true` starts in the background\n- `quit` — graceful quit via AppleScript `tell application … to quit`\n- `force_quit` — SIGKILL without saving\n- `hide` / `show` — toggle app visibility; requires Accessibility\n\n---\n\n### `macos_manage_windows`\n\nWindow operations across all visible apps via System Events Accessibility.\n\n- `list` — all visible windows with app name, title, position, size, minimized state, and display index (0 = primary)\n- `focus` — bring an app or window to the foreground (does not require Accessibility)\n- `move` — reposition a window by top-left coordinate\n- `resize` — change a window's width and height\n- `move_resize` — set position and size in one call\n- `minimize` — minimize to Dock or restore; `minimized=true` to minimize, `false` to restore\n- `fullscreen` — toggle fullscreen via ⌃⌘F keystroke\n- `close` — click the close button via Accessibility\n- Target by `app_name`, `window_title`, or both (`window_title` takes precedence)\n- All mutating actions (everything except `list` and `focus`) require Accessibility\n\n---\n\n### `macos_control_volume`\n\n- `get` — returns current output volume (0–100) and mute state\n- `set` — accepts `level` (0–100), `muted` (true/false), or both; setting `level=0` does not mute\n- Always returns current state after a `set`\n\n---\n\n### `macos_control_audio`\n\nAudio device routing via SwitchAudioSource CLI (`brew install switchaudio-osx`).\n\n- `list` — all input and output devices, with `is_default` flag; filter by `type=input|output|all`\n- `current` — current default input and output device names\n- `switch_output` / `switch_input` — change the default device; supports case-insensitive partial name matching (`\"MacBook\"` matches `\"MacBook Pro Microphone\"`)\n- Volume level control is separate (`macos_control_volume`)\n\n---\n\n### `macos_control_appearance`\n\n- `get` — returns `dark_mode: true/false`\n- `set` with `mode=dark|light|toggle` — `dark`/`light` are idempotent; `toggle` flips on each call\n\n---\n\n### `macos_control_system`\n\n- `lock` — locks the screen immediately via ⌃⌘Q (Accessibility); falls back to ScreenSaverEngine binary if Accessibility is not granted\n- `sleep_display` — puts all displays to sleep via `pmset displaysleepnow`; no permissions required\n\n---\n\n### `macos_take_screenshot`\n\nSaves a full-resolution PNG to disk; optionally returns a downscaled JPEG preview as base64.\n\n- `screen` — full screen capture (all displays merged); no Screen Recording required\n- `display` — a specific display by 0-based `display_index`; no Screen Recording required\n- `window` — a named app window by `app_name`; **requires Screen Recording**\n- `region` — a pixel rectangle `{ x, y, width, height }`; no Screen Recording required\n- `path` — custom output path (must be within `~/Desktop`, `/tmp`, or home dir); defaults to `MACOS_SCREENSHOT_DIR/\u003ctimestamp\u003e.png` (falls back to `~/Desktop`)\n- `include_data=true` — adds `preview` (base64 JPEG, max 1024px wide, ~70% quality) + `preview_width` / `preview_height` to the response for agent visual analysis\n\n---\n\n### `macos_manage_displays`\n\nRequires displayplacer CLI (`brew install jakehilborn/jakehilborn/displayplacer`).\n\n- `list` — connected display inventory: persistent ID, connection type, resolution, refresh rate, origin, rotation, scaling, enabled state; plus `current_config` (a displayplacer command string that reproduces the active arrangement)\n- `apply_layout` — activates a named preset from `MACOS_DISPLAY_LAYOUTS`; layout names are pre-configured in the env var — raw displayplacer args are never accepted from the user\n\n---\n\n### `macos_send_notification`\n\nPosts to Notification Center via osascript. Does not require notification permission — osascript notifications bypass Do Not Disturb.\n\n- `title` (required), `body`, `subtitle`, `sound=true` (plays default notification sound)\n- Each call creates a new notification; not idempotent\n\n---\n\n### `macos_manage_focus`\n\n- `get` — best-effort: reads `~/Library/DoNotDisturb/DB/Assertions.json` when accessible; returns `status: active|inactive|unknown`; `unknown` is expected on macOS 13+ where the database is SIP-protected\n- `set` — requires the built-in `\"Set Focus\"` shortcut to exist in Shortcuts.app (present by default on macOS 12+); `mode` must match a configured Focus profile exactly (e.g. `\"Do Not Disturb\"`, `\"Work\"`); `enabled` defaults to `true`\n\n---\n\n### `macos_manage_finder`\n\nFinder integration via osascript and `open`.\n\n- `frontmost_path` — POSIX path of the active Finder window, or `null` when no window is open; no permissions required\n- `get_selection` — POSIX paths of selected items; requires Automation \u003e Finder permission\n- `reveal` — highlight a path in Finder (`open -R path`)\n- `open_with` — open a path with a named app (`open -a AppName path`)\n- `trash` — moves a path to the Trash (recoverable); not a permanent delete\n\n## Resources\n\n| Type | Name | Description |\n|:-----|:-----|:------------|\n| Resource | `macos://system/info` | Current macOS system snapshot: battery, power source, Wi-Fi SSID, hostname, version, uptime, display count |\n| Resource | `macos://audio/devices` | All audio input and output devices, including which is the current default. Requires SwitchAudioSource CLI. |\n| Resource | `macos://displays` | Connected display inventory including persistent IDs, type, resolution, origin, rotation, scaling, and enabled state. Requires displayplacer CLI. |\n\nResource data is also accessible via `macos_get_info`, `macos_control_audio` (`action=list`), and `macos_manage_displays` (`action=list`).\n\n## Features\n\nBuilt on [`@cyanheads/mcp-ts-core`](https://github.com/cyanheads/mcp-ts-core):\n\n- Declarative tool and resource definitions — single file per primitive, framework handles registration and validation\n- Unified error handling — handlers throw, framework catches, classifies, and formats with structured recovery hints\n- Structured logging with optional OpenTelemetry tracing\n- STDIO and Streamable HTTP transports\n\nmacOS-specific:\n\n- osascript service with configurable timeout — wraps both JXA (`runJxa`) and AppleScript (`runAppleScript`)\n- SwitchAudioSource integration for audio device routing (optional dependency — graceful error when absent)\n- displayplacer integration for display management and layout presets (optional dependency — graceful error when absent)\n- screencapture + sips pipeline for PNG capture and JPEG preview generation\n- system_profiler, pmset, and networksetup for hardware state\n- Permission-first design — `macos_check_permissions` tells you exactly which process needs which permission before you hit a `Forbidden` error\n\nAgent-friendly output:\n\n- Permission errors include specific grant instructions (`System Settings \u003e Privacy \u0026 Security \u003e [permission type]`)\n- Optional CLI tools (`SwitchAudioSource`, `displayplacer`) surface `ServiceUnavailable` with install instructions (`brew install …`)\n- `macos_manage_windows action=list` includes `display_index` on every window so agents can reason about multi-monitor layouts\n- `macos_take_screenshot` separates full-resolution disk write from optional base64 preview — keeps response size manageable\n\n## Getting started\n\nThis server is **local-only** — it controls the macOS system it runs on. Use STDIO transport with your MCP client.\n\nAdd the following to your MCP client configuration file:\n\n```json\n{\n  \"mcpServers\": {\n    \"macos-mcp-server\": {\n      \"type\": \"stdio\",\n      \"command\": \"bunx\",\n      \"args\": [\"@cyanheads/macos-mcp-server@latest\"],\n      \"env\": {\n        \"MCP_TRANSPORT_TYPE\": \"stdio\",\n        \"MCP_LOG_LEVEL\": \"info\"\n      }\n    }\n  }\n}\n```\n\nOr with npx (no Bun required):\n\n```json\n{\n  \"mcpServers\": {\n    \"macos-mcp-server\": {\n      \"type\": \"stdio\",\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@cyanheads/macos-mcp-server@latest\"],\n      \"env\": {\n        \"MCP_TRANSPORT_TYPE\": \"stdio\",\n        \"MCP_LOG_LEVEL\": \"info\"\n      }\n    }\n  }\n}\n```\n\n### Prerequisites\n\n- macOS 12 (Monterey) or higher.\n- [Bun v1.3.0](https://bun.sh/) or higher (or Node.js v24+).\n- Optional: [SwitchAudioSource](https://github.com/deweller/switchaudio-osx) for audio routing (`brew install switchaudio-osx`).\n- Optional: [displayplacer](https://github.com/jakehilborn/displayplacer) for display management (`brew install jakehilborn/jakehilborn/displayplacer`).\n\nSome tools require macOS permissions granted to the terminal or MCP host app:\n\n| Permission | Required by |\n|:-----------|:------------|\n| Accessibility | `macos_manage_windows` (mutating actions), `macos_manage_apps` (hide/show), `macos_control_system` (lock) |\n| Screen Recording | `macos_take_screenshot` with `target=window` |\n| Automation \u003e Finder | `macos_manage_finder` with `action=get_selection` |\n\nUse `macos_check_permissions` to check current status before running permission-gated operations.\n\n### Installation\n\n1. **Clone the repository:**\n\n```sh\ngit clone https://github.com/cyanheads/macos-mcp-server.git\n```\n\n2. **Navigate into the directory:**\n\n```sh\ncd macos-mcp-server\n```\n\n3. **Install dependencies:**\n\n```sh\nbun install\n```\n\n4. **Configure environment:**\n\n```sh\ncp .env.example .env\n# edit .env if you want to set MACOS_SCREENSHOT_DIR or MACOS_DISPLAY_LAYOUTS\n```\n\n## Configuration\n\n| Variable | Description | Default |\n|:---------|:------------|:--------|\n| `MACOS_SCREENSHOT_DIR` | Default directory for screenshot files. | `~/Desktop` |\n| `MACOS_DISPLAY_LAYOUTS` | JSON object mapping layout names to displayplacer argument strings. Used by `macos_manage_displays action=apply_layout`. | `{}` |\n| `MCP_TRANSPORT_TYPE` | Transport: `stdio` or `http`. | `stdio` |\n| `MCP_HTTP_PORT` | Port for HTTP server. | `3010` |\n| `MCP_AUTH_MODE` | Auth mode: `none`, `jwt`, or `oauth`. | `none` |\n| `MCP_LOG_LEVEL` | Log level. | `info` |\n| `OTEL_ENABLED` | Enable OpenTelemetry instrumentation. | `false` |\n\nSee [`.env.example`](./.env.example) for the full list of optional overrides.\n\n**Display layout example:**\n\n```sh\n# Get the current displayplacer command for your setup:\ndisplayplacer list\n\n# Then configure named layouts in your env:\nMACOS_DISPLAY_LAYOUTS='{\"office\":\"id:1234 res:2560x1440 hz:60 color_depth:8 scaling:on origin:(0,0) degree:0 id:5678 res:1920x1080 hz:60 color_depth:8 scaling:on origin:(2560,0) degree:0\"}'\n```\n\n## Running the server\n\n### Local development\n\n```sh\n# One-time build\nbun run rebuild\n\n# Run the built server\nbun run start:stdio\n\n# Run checks\nbun run devcheck   # Lint, format, typecheck, security, changelog sync\nbun run test       # Vitest test suite\nbun run lint:mcp   # Validate MCP definitions against spec\n```\n\n### Docker\n\n```sh\ndocker build -t macos-mcp-server .\ndocker run --rm -p 3010:3010 macos-mcp-server\n```\n\nThe Dockerfile defaults to HTTP transport, stateless session mode, and logs to `/var/log/macos-mcp-server`. Note: the Docker image cannot exercise osascript or system CLI tools — it is provided for completeness but has limited utility for this server.\n\n## Project structure\n\n| Path | Purpose |\n|:-----|:--------|\n| `src/index.ts` | `createApp()` entry — registers tools/resources and inits services |\n| `src/config/server-config.ts` | `MACOS_SCREENSHOT_DIR` and `MACOS_DISPLAY_LAYOUTS` env parsing |\n| `src/mcp-server/tools/definitions/` | 13 tool definitions (`macos-*.tool.ts`) |\n| `src/mcp-server/resources/definitions/` | 3 resource definitions (`macos-*.resource.ts`) |\n| `src/services/osascript/` | osascript JXA + AppleScript runner with configurable timeout |\n| `src/services/audio/` | SwitchAudioSource device listing and switching |\n| `src/services/display/` | displayplacer list and apply-layout |\n| `src/services/screencapture/` | screencapture + sips PNG capture and JPEG preview |\n| `src/services/system-info/` | Battery, Wi-Fi, hostname, uptime via system_profiler/pmset |\n| `tests/tools/` | Tool tests mirroring definitions |\n\n## Development guide\n\nSee [`CLAUDE.md`](./CLAUDE.md) for development guidelines and architectural rules. The short version:\n\n- Handlers throw, framework catches — no `try/catch` in tool logic\n- Use `ctx.log` for request-scoped logging; no `console` calls\n- All tool names are prefixed `macos_` and use snake_case; file names are `macos-*.tool.ts`\n- Services are singletons initialized in `createApp()` and accessed via `get*Service()` accessors\n\n## Contributing\n\nIssues and pull requests are welcome. Run checks and tests before submitting:\n\n```sh\nbun run devcheck\nbun run test\n```\n\n## License\n\nApache-2.0 — see [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyanheads%2Fmacos-mcp-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcyanheads%2Fmacos-mcp-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcyanheads%2Fmacos-mcp-server/lists"}