macos-computer-use-mcp
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
macos-computer-use-mcp
Local macOS Computer Use MCP server built with TypeScript (@modelcontextprotocol/sdk + zod) and a native Swift CLI bridge (CoreGraphics, AppKit, screencapture) — with zero third-party GUI control dependencies.
Architecture
macos-computer-use-mcp/
├── .agents/
│ ├── rules/ # Reusable computer-use safety rules
│ └── skills/ # Agent runbook skill for macos-computer-use
├── native/
│ └── MacosControlBridge.swift # Native Swift CLI (windows, capture, focus, mouse, keyboard, observe, ax-action)
├── src/
│ ├── index.ts # MCP stdio entrypoint
│ ├── server.ts # MCP tool registration (12 tools)
│ ├── cdp.ts # Isolated background Chrome CDP manager
│ ├── receipt.ts # Unified Action Receipt normalization & secret redaction
│ ├── security.ts # Allowlist, sensitive-app blocklist, input mode policy, coordinates
│ ├── native-bridge.ts # Subprocess wrapper & structured error mapping
│ └── schemas.ts # Zod input validation schemas
├── test/
│ ├── bridge.integration.test.ts # Native Swift bridge integration tests
│ ├── cdp.test.ts # CDP unit & full MCP client E2E tests
│ ├── schemas.test.ts # Unit tests for Zod schemas
│ ├── security.test.ts # Unit tests for allowlist, blocklist, coordinates, input mode
│ └── e2e/ # Manual/interactive E2E acceptance scripts
├── scripts/
│ └── build-native.sh # Compiles Swift binary to bin/macos-control-bridge
├── bin/ # Compiled Swift binary (gitignored)
└── dist/ # Compiled TypeScript output (gitignored)Related MCP server: mcp-macos-cua
Input Modes (background_strict vs foreground)
The server enforces a trusted MACOS_CONTROL_INPUT_MODE environment variable (agents cannot elevate to foreground via tool arguments):
background_strict(default): Zero hardware mouse movement, zero focus stealing, zeroactivate/AXRaise, zero clipboard usage, and zero automatic foreground fallback. Routes native macOS apps viaAXUIElement(observe_window+ax_action) +ScreenCaptureKit(capture_window), and managed browsers viacdp_*tools.background_compatible: Reserved (returnsBACKGROUND_INPUT_UNSUPPORTEDin P0/P2).foreground: Opt-in via trusted configMACOS_CONTROL_INPUT_MODE=foreground. Enablesfocus_app,mouse_action,keyboard_action, andax_actioncoordinateFallback: true.
Supported Capability Matrix
Target Type | Backend | Background-Safe | Supported Actions | Limitations |
Native macOS apps (AppKit/Cocoa) |
| Yes |
| Elements without AX support return |
Managed Browser (isolated Chrome via | Chrome DevTools Protocol ( | Yes |
| Uses isolated temp profile; |
Non-AX / Non-CDP apps (unmanaged Chrome/Electron, custom canvas, games) | None in | No | Observation only ( | Background pixel input is unsupported without foreground opt-in |
Tools (12)
list_windows— Lists visible windows belonging to allowlisted apps (windowId,appName,bundleId,title,bounds,isFrontmost).capture_window— Captures a specific window bywindowIdin-memory viaScreenCaptureKit(SCScreenshotManager) and returns a PNG image along withbounds(in macOS points),scaleFactor,imageWidth,imageHeight, andcoordinateUnit: "points".focus_app— Brings an allowlisted app to the foreground bywindowId,appName, orbundleId(usingAXRaisewhenwindowIdis provided). Blocked inbackground_strict.mouse_action—click,double_click,move,drag,scrollviaCGEvent. SupportscoordinateSpace: "window"(macOS points),"image_pixels"(raw PNG pixels fromcapture_window, automatically divided byscaleFactor), and"screen". Blocked inbackground_strict.keyboard_action—type_text(prefers direct AccessibilitykAXSelectedTextAttributeinjection with read-back verification, falling back toCGEventUnicode keystrokes only when the focused element does not support AX; returnsmethodandverified),paste_text(clipboard-safeNSPasteboard+Cmd+Vpreserving all item types and checkingchangeCount), andkey_press. Blocked inbackground_strict.observe_window— Traverses the nativeAXUIElementtree of an allowlisted window (maxDepth,maxNodes,maxPayloadBytesbounded) and returns asnapshotId, UI state, and elements (elementId,role,label,value,bounds,actions).ax_action— Performs semantic AX actions (press,focus,set_value,increment,decrement,show_menu,confirm,cancel) bysnapshotId+elementIdwith stale-target protection, read-back verification, and Unified Action Receipt (executionStatus,verificationStatus,resultCode,actionId,backend,target,durationMs,evidence, advisorysafeToRetry).cdp_session— Manages an isolated background Chrome CDP session (start,close,status,list_tabs,new_tab,select_tab,close_tab) using a temp--user-data-dirand127.0.0.1ephemeral port (headless: truedefault;headless: falserequiresMACOS_CONTROL_CDP_ALLOW_HEADFUL=1). Inbackground_strict, requireschrome-headless-shell(or explicitMACOS_CONTROL_CDP_BROWSER_PATH/MACOS_CONTROL_CDP_ALLOW_CHROME_FALLBACK=1).cdp_navigate— Navigates a managed CDP tab tohttp://,https://, orabout:URLs (file://disabled unlessMACOS_CONTROL_CDP_ALLOW_FILE_URLS=1) without activating or bringing it to front; supports optionalexpectedOutcomeverification.cdp_observe— Inspects interactive DOM elements (elementId,tag,role,label,value,selector,bounds) in a managed CDP tab.cdp_screenshot— Captures a PNG screenshot of a managed CDP tab viaPage.captureScreenshot(works even when headless or occluded).cdp_action— Performs background CDP input (click,double_click,text_input,key_press,scroll,drag_and_drop) on a managed Chrome tab with zero OS mouse/focus/clipboard interference and optionalexpectedOutcomeverification (element_visible,element_hidden,text_equals,value_equals,url_matches,element_countinfinal_stateorstate_transitionmode).
Safe Rollback
Distinguish safely preserving local development changes from rolling back a published release:
Preserve local uncommitted work (note:
git diffonly captures tracked changes and excludes untracked files;git checkout <branch>does not guarantee removal of uncommitted changes):
git status -u # inspect both modified and untracked files
git stash push -u -m "wip-backup" # safely save tracked + untracked changes
# or for tracked diffs only:
git diff > /tmp/local-backup.patch
git checkout -p -- src/ native/ test/ README.md
npm run buildRoll back a published release (after committing/releasing on
main):
git checkout main
git revert <release-commit-sha> # non-destructive history-preserving rollback
# or inspect/pin the previous release tag directly:
git checkout v0.1.0Known Limitations & Untested Scenarios
CGEventfallback focus race &virtualKey: 49(observed keyboard leakage): Whentype_text(foreground-only mode) falls back tocgevent_unicodeon elements that do not supportkAXSelectedTextAttribute,CGEventis posted asynchronously to the HID queue usingvirtualKey: 49(Space keyCode) withkeyboardSetUnicodeStringattached. Although the bridge re-verifies the frontmost app andAXFocusedWindowbefore every keystroke (aborting withFOCUS_LOST), a concurrent window switch during the ~6–24ms in-flight window of a single keystroke has been observed to deliver 1 leaked character to the newly focused window. This remains an inherent limitation of theCGEventfallback path inforegroundmode. The primaryax_selected_textpath (background_strict/ax_actionset_value) andcdp_actiondo not useCGEventand have 0 leaked characters. Do not useCGEventfallback for sensitive targets (terminals, chats, or password fields —Terminal,iTerm2,Warp,Alacritty,Kitty,Ghostty,WezTerm,Hyper, andKeychain Accessare hardcoded inSENSITIVE_APP_BLOCKED).Occlusion guard TOCTOU race &
movescope: Coordinate actions (mouse_actionclick/double_click/drag/scrollandax_actioncoordinateFallback) verifyCGWindowListCopyWindowInfoz-order right before postingCGEvent(requiringwindowId).mouse_actionmoveintentionally does not run theverifyWindowTopmostAtocclusion guard. Because the z-order check and the HID event dispatch are not atomic in macOS, a window appearing during the few milliseconds betweenverifyWindowTopmostAtandCGEvent.postis an inherent TOCTOU race.verified: falsedoes not auto-fallback: Whentype_textsucceeds viaax_selected_text(kAXSelectedTextAttributeis settable and returns success) but read-back verification cannot confirm the text (verified: false), the bridge intentionally returns{ method: "ax_selected_text", verified: false }without falling back tocgevent_unicodeso text is never double-typed.Headless Chrome
.appfocus handoff (strictly opt-in since v0.1.1): Launching/Applications/Google Chrome.app/Contents/MacOS/Google Chrome --headless=newwhile anotherGoogle Chromeinstance is already running can cause macOS LaunchServices to activate the existingGoogle Chromewindow. Inbackground_strictmode,cdp_sessionrefuses to fall back toGoogle Chrome.appautomatically (and also blocksMACOS_CONTROL_CDP_BROWSER_PATHif it resolves to a non-chrome-headless-shellbinary such asGoogle Chrome.app), returningCDP_BROWSER_NOT_FOUNDorFOREGROUND_PERMISSION_REQUIRED. To opt intoGoogle Chrome.appfallback with reduced non-interference guarantees, explicitly setMACOS_CONTROL_CDP_ALLOW_CHROME_FALLBACK=1(orMACOS_CONTROL_INPUT_MODE=foreground). Native AX tools (observe_window,ax_action,list_windows,capture_window) continue working normally when the CDP backend is unavailable.Untested scenarios:
Telex IME active: E2E tests ran with the
ABCkeyboard layout (20/20pass);cgevent_unicodewith macOS Telex IME enabled has not been tested.Secondary / external displays:
capture_window+mouse_action(image_pixels) has been tested on the built-in Retina display (1680x1050 @ 2.0x); multi-monitor / external display scaling has not been tested.Heavy Electron apps under
paste_text: Clipboard PNG preservation was verified on TextEdit; slow Electron apps have not been tested.
Security (Least Privilege)
Mandatory Allowlist (
MACOS_CONTROL_ALLOWLIST): Comma-separated app names or bundle IDs (e.g.Simulator,TextEdit,com.apple.iphonesimulator). If empty or unset, all operations are rejected (ALLOWLIST_EMPTY).Sensitive App Blocklist:
Terminal,iTerm2,Warp,Alacritty,Kitty,Ghostty,WezTerm,Hyper,Keychain Access, andSystem Settings(System Preferences) are always blocked (SENSITIVE_APP_BLOCKED), even if added toMACOS_CONTROL_ALLOWLIST.Window-Relative Coordinates & Active App Guard:
mouse_actiondefaults tocoordinateSpace: "window"(rejecting out-of-bounds coordinates), and bothmouse_actionandkeyboard_actionverify that the frontmost active app is allowlisted and matches the targetwindowId.Dual-Layer Enforcement: Security checks are enforced in both the TypeScript MCP layer and the native Swift binary.
Requirements
macOS 14.0+ (Sonoma or later) — required for
ScreenCaptureKit(SCScreenshotManager).Node.js >= 22.0.0 — required for built-in global
WebSocketandfetch.Swift toolchain (
xcode-select --installor Xcode) — required to compilenative/MacosControlBridge.swift.chrome-headless-shell/ Google Chrome (optional, forcdp_*tools; native AX tools work without it) — discovers executablechrome-headless-shellonPATH,/opt/homebrew/bin,/usr/local/bin,~/.local/bin,~/bin,~/.local/share/chrome-headless-shell,/Applications/chrome-headless-shell, or optional Puppeteer/Playwright caches (validating symlinks viarealpath).MACOS_CONTROL_CDP_BROWSER_PATHselects a binary path only and does not implicitly authorize non-chrome-headless-shellbinaries inbackground_strict;MACOS_CONTROL_CDP_ALLOW_CHROME_FALLBACK=1(orMACOS_CONTROL_INPUT_MODE=foreground) is required to permitGoogle Chrome.appfallback.
Build & Test
npm install
npm run build
npm run test:ci # Permission-independent unit & validation tests (also runs in CI)
npm test # Full local suite (includes macOS Accessibility/GUI & Chrome CDP E2E tests; keep desktop idle)Register Globally in Antigravity
Add the following entry to your global Antigravity mcp_config.json (typically ~/.gemini/antigravity/mcp_config.json):
{
"mcpServers": {
"macos-computer-use": {
"command": "node",
"args": [
"/path/to/macos-computer-use-mcp/dist/index.js"
],
"env": {
"MACOS_CONTROL_ALLOWLIST": "Simulator,TextEdit"
}
}
}
}Adjust
MACOS_CONTROL_ALLOWLISTto only the specific apps you want to automate.
Required macOS Permissions
Grant both permissions in System Settings → Privacy & Security to the host application/process running the MCP server (e.g., Antigravity / Node):
Screen Recording — required for
capture_window(screencapture -l).Accessibility — required for
mouse_actionandkeyboard_action(CGEventposting).
If either permission is missing, the server returns a clear SCREEN_RECORDING_DENIED or ACCESSIBILITY_DENIED error.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Let AI agents use your real, signed-in Chrome: tabs, clicks, forms, screenshots and video.
Monitor your Mac and let AI agents report progress or request human help.
Connect AI assistants to your approved computer for files, commands, browser and desktop tasks.
Let AI see and use your own Windows PC with your permission: screen, apps, mouse and keyboard.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides native macOS desktop automation for AI agents, enabling screen capture, mouse/keyboard control, window management, and iOS/Android simulator control in both foreground and background modes without focus stealing.6MIT
- AlicenseAqualityDmaintenanceEnables AI agents to control macOS desktop apps via screenshots, mouse clicks, keyboard input, accessibility queries, and AppleScript.1111 npmMIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to observe and control the user's live desktop by listing apps, reading accessibility trees, and performing clicks, typing, scrolling, dragging, and other input actions with per-action approvals and local audit archives.1MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to discover and control allowed macOS apps in the background through accessibility trees, window screenshots, and semantic actions over a local stdio interface.MIT