mcp-macos-cua

mcp-macos-cua

Enables AI agents to control macOS desktop apps via screenshots, mouse clicks, keyboard input, accessibility queries, and AppleScript.

Category
访问服务器

README

mcp-macos-cua

A macOS Computer Use Agent (CUA) — an MCP server that gives AI agents full GUI automation capabilities on macOS.

Control any desktop app through screenshots, mouse clicks, keyboard input, accessibility queries, and AppleScript.

Optimized for Claude Code — includes a ready-to-use /cua skill with automatic permission bootstrap. Also works as a standalone MCP server with any MCP-compatible agent.

Features

Tool Description
screenshot Capture full screen or specific app window (auto-detects display scale factor)
open_app Open and activate any macOS application
click Click at screen coordinates (single, double, left, right)
type_text Type text into the frontmost app
key_press Press keys/combos (cmd+c, cmd+shift+a, return, etc.)
scroll Scroll in any direction at current or given position
get_ui_elements Inspect accessibility tree of an app window
click_ui_element Click buttons/elements by name via accessibility
run_applescript Execute arbitrary AppleScript
get_mouse_position Get current cursor position
move_mouse Move cursor to coordinates

Prerequisites

  • macOS (required — uses macOS-specific APIs)
  • Node.js 18+
  • cliclickbrew install cliclick
  • Accessibility permissions — System Settings > Privacy & Security > Accessibility (grant to your terminal app)
  • Screen Recording permissions — System Settings > Privacy & Security > Screen Recording (grant to your terminal app)
  • Python 3 with pyobjc-framework-Quartz — usually pre-installed on macOS; if not: pip3 install pyobjc-framework-Quartz

You may need to restart your terminal after granting macOS permissions.


Installation

Option A: Claude Code Plugin (Recommended)

The plugin gives you the full experience: an MCP server, a /cua skill with guided CUA loop, and automatic permission bootstrap.

From the marketplace — run these commands inside Claude Code:

/plugin marketplace add bradthebeeble/claude-plugins
/plugin install mcp-macos-cua@bradthebeeble-plugins

From local source — for development/testing (from the shell):

claude --plugin-dir /path/to/mcp-macos-cua

After installing, start using it immediately:

/mcp-macos-cua:cua open Safari and search for today's weather

Auto-permissions: On first use, the /cua skill detects whether CUA tool permissions are configured. If not, it asks once to allow all CUA tools — no more per-tool prompts for the rest of the project.

Option B: Any MCP-Compatible Agent (npx)

The MCP server is published on npm and works with any agent that supports the Model Context Protocol — no plugin system required.

Add this to your MCP client config:

{
  "mcpServers": {
    "cua": {
      "command": "npx",
      "args": ["-y", "mcp-macos-cua"]
    }
  }
}

npx downloads the package and all dependencies automatically on first run, and caches them for subsequent calls.

Where to put this config:

Agent Config location
Claude Code .mcp.json in your project root
Cursor Settings > MCP > Add server
Windsurf MCP settings
Claude Desktop claude_desktop_config.json
Custom Your MCP client config file

Note for Claude Code users: Using the MCP server directly (without the plugin) gives you the raw tools but not the /cua skill, the guided CUA loop, or the auto-permission bootstrap. To avoid per-tool permission prompts, add "mcp__cua__*" to permissions.allow in .claude/settings.local.json.

Option C: Clone and Run

For development or when you want to run the server directly:

git clone https://github.com/bradthebeeble/mcp-macos-cua.git
cd mcp-macos-cua
npm install
node server/index.js

The server communicates via stdio — connect your MCP client to the process.


System Prompt for Non-Plugin Usage

When using the MCP server without the Claude Code plugin (Options B or C), your agent needs instructions on how to use the tools effectively. Add this to your agent's system prompt:

<details> <summary>CUA System Prompt (click to expand)</summary>

You are a Computer Use Agent (CUA) on macOS. Interact with the GUI using the cua MCP tools.

## CUA Loop
1. Screenshot - Take a screenshot to see current state
2. Analyze - Determine what action to take next
3. Act - Use the appropriate tool (click, type_text, key_press, etc.)
4. Verify - Screenshot again to confirm it worked
5. Repeat or Report - Continue or summarize results

## Coordinate System
The screenshot tool returns a display scale factor (e.g. 2x for Retina, 1x for standard).
Divide screenshot pixel positions by this scale factor to get correct tool coordinates.
Example: if scale factor is 2x and you see a button at pixel (800, 400) in the screenshot,
click at coordinates (400, 200).

## Available Tools
- screenshot - Capture screen (optionally a specific app)
- open_app - Open and activate an application
- click - Click at coordinates (x, y in screen points)
- type_text - Type text into frontmost app
- key_press - Press keys/combos (e.g. "cmd+c", "return", "cmd+shift+a")
- scroll - Scroll in a direction at a position
- get_ui_elements - Inspect accessibility tree of an app
- click_ui_element - Click an element by name via accessibility
- run_applescript - Execute arbitrary AppleScript
- get_mouse_position - Get current cursor position
- move_mouse - Move cursor to coordinates

## Tips
- Always start with a screenshot before acting
- Prefer click_ui_element (accessibility) over coordinate click when possible
- Use get_ui_elements to discover clickable elements by name
- Use key_press for keyboard shortcuts (faster than navigating menus)
- Use scroll with x,y to scroll within a specific area
- Use run_applescript as escape hatch for complex multi-step automation

</details>


Usage

The CUA Loop

Whether via the /cua skill or a custom system prompt, the agent follows a Screenshot > Analyze > Act > Verify > Repeat loop:

  1. Takes a screenshot to see the current screen state
  2. Analyzes what action to take next
  3. Executes the action (click, type, etc.)
  4. Takes another screenshot to verify the result
  5. Repeats until the task is complete

Coordinate System

The screenshot tool automatically detects the display scale factor (2x for Retina, 1x for standard displays) and returns it with every screenshot. Divide screenshot pixel positions by this factor to get correct tool coordinates.

Examples (Claude Code plugin)

/mcp-macos-cua:cua open Slack and send "hello" to the #general channel
/mcp-macos-cua:cua take a screenshot of Safari
/mcp-macos-cua:cua open Notes and create a grocery list
/mcp-macos-cua:cua open System Settings and enable Dark Mode

Tools Reference

screenshot

Param Type Required Description
app string No App name to screenshot. Omit for full screen.

Returns the screenshot image and the display scale factor.

click

Param Type Required Description
x number Yes X coordinate in screen points
y number Yes Y coordinate in screen points
clicks number No 1 (single) or 2 (double). Default: 1
button string No "left" or "right". Default: "left"

type_text

Param Type Required Description
text string Yes Text to type into frontmost app

key_press

Param Type Required Description
keys string Yes Key combo like "cmd+c", "return", "cmd+shift+a"

scroll

Param Type Required Description
direction string Yes "up", "down", "left", "right"
amount number No Scroll steps. Default: 3
x, y number No Coordinates to scroll at (moves mouse first)

open_app

Param Type Required Description
app string Yes Application name (e.g. "Safari", "Slack")

get_ui_elements

Param Type Required Description
app string Yes Application process name
depth string No "shallow" (default) or "deep" (full tree, slow)

click_ui_element

Param Type Required Description
app string Yes Application process name
element_type string Yes e.g. "button", "menu item", "text field"
name string Yes Name/title of the element
path string No Parent path. Default: "window 1"

run_applescript

Param Type Required Description
script string Yes AppleScript code to execute

get_mouse_position

No parameters. Returns current cursor position.

move_mouse

Param Type Required Description
x number Yes X coordinate in screen points
y number Yes Y coordinate in screen points

Adding to a Team Marketplace

To distribute the Claude Code plugin within your team, add it to a Claude Code plugin marketplace:

  1. Create or locate your team's marketplace.json
  2. Add the plugin entry:
{
  "plugins": [
    {
      "name": "mcp-macos-cua",
      "description": "macOS Computer Use Agent - GUI automation via screenshots, clicks, typing, accessibility, and AppleScript",
      "source": "github:bradthebeeble/mcp-macos-cua"
    }
  ]
}
  1. Team members can then install from inside Claude Code:
/plugin marketplace add your-org/your-marketplace-repo
/plugin install mcp-macos-cua@your-marketplace

Troubleshooting

"cliclick not found" — Install with brew install cliclick

Clicks land in wrong position — Check the scale factor returned by screenshot. Divide pixel coordinates by that factor.

"not allowed assistive access" — Grant Accessibility permissions in System Settings > Privacy & Security > Accessibility to your terminal app. Restart the terminal after granting.

Scroll not working — Install pyobjc: pip3 install pyobjc-framework-Quartz

Permission prompts on every CUA tool call (Claude Code) — The auto-permission bootstrap only runs via the /cua skill (plugin install). If using manual MCP config, add "mcp__cua__*" to permissions.allow in .claude/settings.local.json.

MCP server not starting — Verify npx -y mcp-macos-cua runs from your terminal. Check that Node.js 18+ is installed.


Security

This tool has full GUI control over your Mac. It can click, type, and run AppleScript as your user. Only use it in trusted environments and review what the agent is doing via the screenshot-verify loop.

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选