经 AI Skill Hub 精选评估,Safari MCP 获评「推荐使用」。这款MCP工具在功能完整性、社区活跃度和易用性方面表现出色,AI 评分 7.5 分,适合有一定技术背景的用户使用。
Safari MCP 是一款遵循 MCP(Model Context Protocol)标准协议的 AI 工具扩展。通过 MCP 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。
Safari MCP 是一款遵循 MCP(Model Context Protocol)标准协议的 AI 工具扩展。通过 MCP 协议,它可以让 Claude、Cursor 等主流 AI 客户端直接访问和操作外部工具、数据源和服务,实现 AI 能力的无缝扩展。无论是文件操作、数据库查询还是 API 调用,都可以通过自然语言在 AI 对话中直接触发,极大提升生产效率。
# 方式一:通过 Claude Code CLI 一键安装
claude skill install https://github.com/achiya-automation/safari-mcp
# 方式二:手动配置 claude_desktop_config.json
{
"mcpServers": {
"safari-mcp": {
"command": "npx",
"args": ["-y", "safari-mcp"]
}
}
}
# 配置文件位置
# macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
# Windows: %APPDATA%/Claude/claude_desktop_config.json
# 安装后在 Claude 对话中直接使用 # 示例: 用户: 请帮我用 Safari MCP 执行以下任务... Claude: [自动调用 Safari MCP MCP 工具处理请求] # 查看可用工具列表 # 在 Claude 中输入:"列出所有可用的 MCP 工具"
// claude_desktop_config.json 配置示例
{
"mcpServers": {
"safari_mcp": {
"command": "npx",
"args": ["-y", "safari-mcp"],
"env": {
// "API_KEY": "your-api-key-here"
}
}
}
}
// 保存后重启 Claude Desktop 生效
<img src="social-preview.png" alt="Safari MCP Server — 97 native browser automation tools for AI agents on macOS" width="100%">
<br/>
---
xcodebuild -project "xcode/Safari MCP/Safari MCP.xcodeproj" \ -scheme "Safari MCP (macOS)" -configuration Release \ -allowProvisioningUpdates clean build
The safari_native_click, safari_native_keyboard and safari_native_hover tools inject OS-level CGEvent events into Safari without stealing focus. macOS requires the underlying helper binary to be approved in Accessibility before those events can reach a non-frontmost window.
1. Open System Settings → Privacy & Security → Accessibility. 2. Click + (unlock with your password if needed). 3. Navigate to the helper binary and add it: - npm global install: $(npm root -g)/safari-mcp/safari-helper - npx / project install: ./node_modules/safari-mcp/safari-helper - From source clone: /path/to/safari-mcp/safari-helper 4. Make sure the toggle next to it is ON.
The postinstall script re-signs the helper with a stable identifier (com.achiya-automation.safari-mcp) so this permission survives future upgrades — without that step, every npm update would silently revoke approval because the binary's adhoc-signed identifier changes per build.
If safari_native_click reports success but the page doesn't react (no isTrusted: true click events fire), the helper is most likely missing this approval. The safari_* (non-native_) tools don't need it.
npx safari-mcp
That's it — no global install needed. Or install permanently:
npm install -g safari-mcp
The extension requires a one-time build with Xcode (free, included with macOS).
Note for npm users: The xcode/ directory is not included in the npm package. Clone the GitHub repository to build from source.
Prerequisites: Xcode (install from App Store — free)
```bash
The recommended pattern for AI agents using Safari MCP:
1. safari_snapshot → Get page state (accessibility tree)
2. safari_click/fill/... → Interact with elements by ref
3. safari_snapshot → Verify the result
Element targeting — tools accept multiple targeting strategies:
| Strategy | Example | Best for |
|---|---|---|
| CSS selector | #login-btn, .submit | Unique elements |
| Visible text | "Sign In", "Submit" | Buttons, links |
| Coordinates | x: 100, y: 200 | Canvas, custom widgets |
| Ref from snapshot | ref: "e42" | Any element from accessibility tree |
Tip: Start with safari_snapshot to get element refs, then use refs for precise targeting. This is faster and more reliable than CSS selectors.
---
| Tool | Description |
|---|---|
safari_screenshot | Screenshot as PNG (viewport or full page) |
safari_screenshot_element | Screenshot a specific element |
safari_save_pdf | Export page as PDF |
All clients run Safari MCP the same way — npx safari-mcp. Pick your editor:
<details> <summary><b>Claude Code</b></summary>
claude mcp add safari -- npx safari-mcp
Or edit ~/.mcp.json:
{
"mcpServers": {
"safari": {
"command": "npx",
"args": ["safari-mcp"]
}
}
} </details>
<details> <summary><b>Claude Desktop</b></summary>
Edit ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"safari": {
"command": "npx",
"args": ["safari-mcp"]
}
}
}
Restart Claude Desktop after saving. </details>
<details> <summary><b>Cursor</b></summary>
One-click: Install in Cursor
Or edit .cursor/mcp.json in your project:
{
"mcpServers": {
"safari": {
"command": "npx",
"args": ["safari-mcp"]
}
}
} </details>
<details> <summary><b>VS Code / VS Code Insiders</b></summary>
One-click: Install in VS Code
Or edit .vscode/mcp.json:
{
"servers": {
"safari": {
"type": "stdio",
"command": "npx",
"args": ["safari-mcp"]
}
}
} </details>
<details> <summary><b>Windsurf</b></summary>
Edit .windsurf/mcp.json in your project (or ~/.codeium/windsurf/mcp_config.json globally):
{
"mcpServers": {
"safari": {
"command": "npx",
"args": ["safari-mcp"]
}
}
} </details>
<details> <summary><b>Cline</b></summary>
Open Cline in VS Code → click the MCP icon → Edit MCP Settings → add:
{
"mcpServers": {
"safari": {
"command": "npx",
"args": ["safari-mcp"]
}
}
} </details>
<details> <summary><b>Continue</b></summary>
Edit ~/.continue/config.yaml (or .continue/config.yaml in workspace):
mcpServers:
- name: safari
command: npx
args:
- safari-mcp </details>
<details> <summary><b>Goose</b></summary>
Edit ~/.config/goose/config.yaml:
extensions:
safari:
name: safari
type: stdio
cmd: npx
args:
- safari-mcp
enabled: true </details>
<details> <summary><b>LM Studio</b></summary>
Open LM Studio → Settings → MCP Servers → Add Server:
- Name: safari - Command: npx - Args: safari-mcp </details>
<details> <summary><b>Zed</b></summary>
Open Zed → Settings → search for "Context Servers" and add:
{
"context_servers": {
"safari": {
"command": {
"path": "npx",
"args": ["safari-mcp"]
}
}
}
} </details>
<details> <summary><b>Alternative: Homebrew</b></summary>
brew install achiya-automation/tap/safari-mcp </details>
<details> <summary><b>Alternative: from source</b></summary>
git clone https://github.com/achiya-automation/safari-mcp.git
cd safari-mcp && npm install </details>
---
| Variable | Default | What it does |
|---|---|---|
SAFARI_MCP_HTTP | off | Run one shared HTTP daemon instead of a process per client (see above). |
SAFARI_MCP_HTTP_PORT | 9225 | Port for that daemon. |
SAFARI_PROFILE | unset | Bind sessions to a named Safari profile. Unset = your ordinary windows. |
SAFARI_MCP_ALLOW_USER_TABS | off | Let safari_switch_tab adopt a tab **you** already had open, instead of refusing it (see below). |
SAFARI_MCP_RAISE_ON_NAVIGATE | off | Let navigation bring Safari to the front, and stop the focus guard from putting your previous app back. |
SAFARI_MCP_SCREENSHOT_MAX_WIDTH | unset | Downscale every safari_screenshot to this pixel width (Retina captures are 2× the viewport). Per-call maxWidth overrides it. |
SAFARI_MCP_KEEPALIVE_TAB | off | Keep one daemon-served page open in the profile window so Safari never parks the extension worker between commands. |
SAFARI_MCP_OPEN_WINDOW_CMD | unset | Command run with the profile name when the profile window is absent (e.g. after a reboot). Must open the window without focusing Safari. |
SAFARI_MCP_RAISE_ON_NAVIGATE=1 is for agents whose whole point is showing you a page — a voice assistant answering "open YouTube", a demo driver. Everything else should leave it off: by default Safari MCP works in the background and hands focus back to whatever app you were using, so an agent can drive a page while you keep typing somewhere else.
---
The Safari MCP Extension is optional but recommended. Without it, ~80% of functionality works via AppleScript alone. The extension adds capabilities that AppleScript cannot provide:
| Capability | With Extension | AppleScript Only |
|---|---|---|
| Closed Shadow DOM (Reddit, Web Components) | ✅ Full access | ❌ Invisible |
| Strict CSP sites | ✅ Bypasses via MAIN world | ❌ Often blocked |
| React/Vue/Angular state manipulation | ✅ Deep (Fiber, ProseMirror) | ⚠️ Basic |
| Loading state detection (spinners, skeletons) | ✅ Smart detection | ❌ No |
| Dialog handling (alert/confirm) | ❌ | ✅ Only AppleScript |
| Native OS-level click (CGEvent) | ❌ | ✅ Only AppleScript |
| PDF export | ❌ | ✅ Only AppleScript |
When do you need the extension? If you're automating modern SPAs with closed shadow DOM (e.g., Reddit), sites with strict Content Security Policy, or framework-heavy editors (Draft.js, ProseMirror, Slate).
git clone https://github.com/achiya-automation/safari-mcp.git cd safari-mcp
open "$APP_PATH" ```
Do not ad-hoc re-signSafari MCP.appwithcodesign --deep --sign -. That replaces the Apple Development identity on the wrapper and embedded extension; current Safari can then silently disable or mark the extension as removed. If a previous build was ad-hoc signed, run theclean buildcommand above again.
Alternatively, open xcode/Safari MCP/Safari MCP.xcodeproj directly in Xcode, select your Apple ID under Signing & Capabilities, and click Run. A free personal Apple Developer account is sufficient for local use.
Then in Safari: 1. Safari → Settings → Advanced → enable Show features for web developers 2. Safari → Develop → Allow Unsigned Extensions (required each Safari restart) 3. Safari → Settings → Extensions → enable Safari MCP Bridge
The extension connects automatically to the first local bridge whose declared Safari profile matches its own. The default bridge ports are 9224, 9228, 9232, and 9236; a single-profile setup normally uses 9224.
Note: "Allow Unsigned Extensions" resets every time Safari restarts. You'll need to re-enable it in the Develop menu after each restart. The extension itself stays installed.
Toolbar icon status: - ON — connected to MCP server - OFF — manually disabled via popup - (no badge) — server not running, will auto-reconnect
---
| Feature | Safari MCP | Chrome DevTools MCP | Playwright MCP |
|---|---|---|---|
| CPU/Heat | 🟢 Minimal | 🔴 High | 🟡 Medium |
| Your logins | ✅ Yes | ✅ Yes | ❌ No |
| macOS native | ✅ WebKit | ❌ Chromium | ❌ Chromium/WebKit |
| Browser dependencies | None | Chrome + debug port | Playwright runtime |
| Tools | 97 | ~30 | ~25 |
| File upload | JS (no dialog) | CDP | Playwright API |
| Image paste | JS (no clipboard) | CDP | Playwright API |
| Focus steal | ❌ Background | ❌ Background | ❌ Headless |
| Network mocking | ✅ | ❌ | ✅ |
| Lighthouse | ❌ | ✅ | ❌ |
| Performance trace | ❌ | ✅ | ❌ |
Tip: Use Safari MCP for daily browsing tasks (95% of work) and Chrome DevTools MCP only for Lighthouse/Performance audits.
In July 2026 Apple shipped an official Safari MCP server built on safaridriver — first in Safari Technology Preview 247, and now also in the Safari 27 beta. That's great validation for the category — and it's built for a different job. Apple's server drives an isolated WebDriver automation session for debugging; safari-mcp drives the real Safari you're already logged into.
It has not reached a stable Safari release yet: on macOS 26.5.2 with Safari 26.5.2, safaridriver --help lists --port, --bidi, --enable and --diagnose, and no --mcp (verified 2026-07-23). Check your own machine with safaridriver --help | grep mcp before assuming either way.
| 🦁 safari-mcp *(this repo)* | Apple safaridriver --mcp | |
|---|---|---|
| **Your real logins / cookies** | ✅ Your actual Safari | ⚠️ Isolated automation session — no access to AutoFill or browsing activity |
| **Runs on** | ✅ Stable Safari, every Mac | ⚠️ Safari Technology Preview 247+ or the Safari 27 beta — not in stable Safari 26.5 |
| **Background (no focus steal)** | ✅ Yes | ❌ Dedicated window with a "controlled by automation" banner |
| **Tools** | **97** | ~17 |
| **Storage** (cookies, localStorage, IndexedDB) | ✅ 10 tools | ❌ |
| **Network mocking + throttling** | ✅ Yes | ❌ Read-only network inspection |
| **Device emulation** (iPhone, iPad) | ✅ Yes | ⚠️ Viewport + media type only |
| **Setup** | npx safari-mcp | Enable "remote automation and external agents", then point your client at that build's safaridriver --mcp |
| **Official Apple support** | ❌ Community (MIT) | ✅ Apple, WebDriver-standard |
When Apple's server is the right pick: you specifically want a clean-room, WebDriver-standard session for compatibility debugging and you already run a preview or beta build. For everything else — daily automation on the browser you're already signed into, on the Safari that shipped with your Mac — safari-mcp is built for exactly that.
| Issue | Fix |
|---|---|
| "AppleScript error" | Enable "Allow JavaScript from Apple Events" in Safari → Develop |
| "Not authorized to send Apple events to Safari" | Grant Automation → Safari to your IDE (see above) |
"Not authorized" after npm update | Updating changes the binary's cdhash — macOS silently revokes Automation permission. Re-run the osascript one-liner above to re-grant it |
safari_native_click reports success but page doesn't react | Add safari-helper to **System Settings → Privacy & Security → Accessibility** (see [Granting Accessibility](#granting-accessibility-to-safari-helper-required-for-safari_native_) above). Confirm by attaching a click listener with {capture:true} in the page console — without the grant, no isTrusted: true event fires |
| Screenshots empty | Grant Screen Recording permission to Terminal/VS Code |
| Tab not found | Call safari_list_tabs to refresh tab indices |
| Hebrew keyboard issues | All typing uses JS events — immune to keyboard layout |
| HTTPS blocked | safari_navigate auto-tries HTTPS first, falls back to HTTP |
| Safari steals focus | Ensure you're on latest version — newTab restores your active tab |
---
safari-mcp 是一个专为 macOS 设计的 Safari 浏览器自动化 MCP 服务端。它为 AI Agent 提供了 80 多个原生浏览器自动化工具,能够实现页面导航、点击、表单填写、截图及网络监控等高级功能。与传统的自动化方案不同,它基于 Apple Silicon 上的原生 WebKit 构建,相比 Chrome 能够节省约 60% 的 CPU 占用,且能完美继承用户现有的登录状态、Cookies 和 Session(如 Gmail、GitHub 等),让 AI 能够像真人一样操作你的真实浏览器。
本项目提供强大的自动化能力,包含导航、点击、表单交互、截图、网络请求监控、存储管理及 Accessibility 辅助功能等 80 多种工具。核心优势在于:1. 极低能耗,利用原生 WebKit 实现“零热量”运行;2. 真实环境,无需重新登录,直接复用现有浏览器会话;3. 后台运行,Safari 会在后台静默操作,不会频繁抢占用户窗口;4. 轻量化,无需 Puppeteer 或 Playwright 等沉重的浏览器依赖。
使用本项目需满足以下环境要求:1. 操作系统:运行 Safari 的 macOS 版本;2. 运行环境:Node.js 18+;3. Safari 设置:需在 Safari 的 Settings → Advanced 中勾选“Show features for web developers”;4. 权限配置:需在 Safari 的 Develop 菜单中开启“Allow JavaScript from Apple Events”。此外,若需使用高级交互工具,必须在 macOS 的 Accessibility 设置中授予 safari-helper 相应的辅助功能权限。
安装过程非常简单。你可以直接通过一行命令运行 `npx safari-mcp` 进行即时体验,无需全局安装。若需永久安装,可执行 `npm install -g safari-mcp`。特别注意:如果你需要安装增强功能的 Safari Extension,由于 npm 包���包含 Xcode 工程文件,建议从 GitHub 仓库克隆源码,并使用 Xcode 进行构建。构建完成后,需通过 Xcode 或直接打开 App 来完成 Safari 的插件注册。
推荐的 AI Agent 工作流模式为:首先通过 `safari_snapshot` 获取当前页面的 Accessibility Tree 状态,随后利用 `safari_click`、`safari_fill` 等工具通过元素引用进行交互,最后再次调用 `safari_snapshot` 验证操作结果。在元素定位方面,工具支持多种策略,包括 CSS selector 等,确保 AI 能够精准地操控页面元素。
配置方式取决于你使用的 MCP 客户端。所有客户端均通过 `npx safari-mcp` 命令启动。对于 Claude Code 用户,可以使用 `claude mcp add safari -- npx safari-mcp` 进行添加;对于 Claude Desktop 用户,可以通过编辑 `~/.mcp.json` 配置文件,在 `mcpServers` 字段下手动添加 safari 的 command 和 args 配置项。
安装 Safari Extension 是提升体验的关键(虽然是可选的,但强烈推荐)。虽然仅靠 AppleScript 即可实现约 20% 的基础功能,但安装 Extension 后,你可以获得突破性的能力:例如能够访问 Reddit 等网站的 Closed Shadow DOM、绕过具有严格 CSP 限制的网站(通过 MAIN world 注入)、以及对 React/Vue/Angular 等现代框架的状态进行深度操作,这些都是纯 AppleScript 无法实现的。
针对常见问题,若遇到 "AppleScript error",请检查 Safari 是否开启了 "Allow JavaScript from Apple Events";若提示 "Not authorized to send Apple events to Safari",请在 macOS 设置中授予你的 IDE 自动化控制权限;若在 `npm update` 后出现权限问题,可能是因为二进制文件路径变更���需重新检查权限授权。
高质量的MCP工具,实现Safari自动化
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。
AI Skill Hub 点评:Safari MCP 的核心功能完整,质量良好。对于Claude Desktop / Claude Code 用户来说,这是一个值得纳入个人工具库的选择。建议先在非生产环境试用,再逐步推广。
| 原始名称 | safari-mcp |
| 原始描述 | 开源MCP工具:Native Safari browser automation for AI agents. 80 tools via AppleScript — zero 。⭐93 · JavaScript |
| Topics | ai-agentsapple-siliconapplescriptautomation |
| GitHub | https://github.com/achiya-automation/safari-mcp |
| License | MIT |
| 语言 | JavaScript |
收录时间:2026-05-27 · 更新时间:2026-05-30 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。
选择 Agent 类型,复制安装指令后粘贴到对应客户端