An open API service indexing awesome lists of open source software.

https://github.com/achiya-automation/safari-mcp

Native Safari browser automation for AI agents. 80 tools via AppleScript โ€” zero overhead, keeps logins, runs silently in background. Drop-in alternative to Chrome DevTools MCP with 40-60% less CPU/heat on Apple Silicon.
https://github.com/achiya-automation/safari-mcp

ai-agents ai-tools apple-silicon applescript automation browser-automation claude claude-code cursor devtools llm-tools macos mcp mcp-server model-context-protocol safari safari-mcp web-automation webkit windsurf

Last synced: 6 days ago
JSON representation

Native Safari browser automation for AI agents. 80 tools via AppleScript โ€” zero overhead, keeps logins, runs silently in background. Drop-in alternative to Chrome DevTools MCP with 40-60% less CPU/heat on Apple Silicon.

Awesome Lists containing this project

README

          

Safari MCP Server โ€” 97 native browser automation tools for AI agents on macOS


# ๐Ÿฆ Safari MCP

**The browser for your coding agent.**

*Your real Safari, logged in โ€” no Chrome, no heat, no headless.*

[![npm version](https://img.shields.io/npm/v/safari-mcp)](https://www.npmjs.com/package/safari-mcp)
[![npm downloads](https://img.shields.io/npm/dm/safari-mcp)](https://www.npmjs.com/package/safari-mcp)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![macOS](https://img.shields.io/badge/macOS-only-blue)](https://www.apple.com/macos/)

[![Glama AAA](https://img.shields.io/badge/Glama-AAA_Score-22c55e?logo=ai)](https://glama.ai/mcp/servers/@achiya-automation/safari-mcp)
[![MCP Registry](https://img.shields.io/badge/MCP_Registry-Verified-2563eb)](https://registry.modelcontextprotocol.io/v0/servers?search=achiya-automation)
[![Smithery](https://img.shields.io/badge/Smithery-Listed-7c3aed)](https://smithery.ai/server/@achiya-automation/safari-mcp)
[![MCP Score](https://mcpscoreboard.com/badge/05977769-8762-4e89-aff3-a0c5776843bb.svg)](https://mcpscoreboard.com/server/05977769-8762-4e89-aff3-a0c5776843bb/)

Install in VS Code
Install in VS Code Insiders
Install in Cursor

**97 tools** ยท **No Chrome/Puppeteer/Playwright needed** ยท **~5ms per command** ยท **60% less CPU than Chrome**

[Quick Start](#quick-start) ยท [All 97 Tools](#tools-97) ยท [Examples](examples/) ยท [Why Safari MCP?](#safari-mcp-vs-alternatives) ยท [Architecture](#architecture) ยท [Changelog](CHANGELOG.md)

![Safari MCP Demo](https://github.com/achiya-automation/safari-mcp/raw/main/assets/safari-mcp-promo.gif)

## โŒ Without Safari MCP

Your AI agent needs to browse. So it either:

- **Spins up Chromium via Playwright** โ€” with no logins, no cookies, no sessions
- **Uses Chrome DevTools MCP** โ€” and melts your fan running a second browser
- **Relies on headless scrapers** โ€” blocked by Cloudflare, reCAPTCHA, and bot detection

## โœ… With Safari MCP

Your AI drives the **Safari you're already logged into** โ€” Gmail, GitHub, Ahrefs, Slack, banking.

Native WebKit. ~60% less CPU. Background operation. 97 tools. One `npx` command. macOS only.

> ๐Ÿ“ฐ **Featured on freeCodeCamp:** [How to Connect Your AI Coding Agent to a Browser on macOS](https://www.freecodecamp.org/news/how-to-connect-your-ai-coding-agent-to-a-browser-on-macos/) ยท [HackerNoon: Reverse-Engineering React, Shadow DOM, and CSP](https://hackernoon.com/i-had-to-reverse-engineer-react-shadow-dom-and-csp-to-automate-safari-without-chrome)

> ๐ŸŽ **Apple shipped an official Safari MCP** (Safari Technology Preview 247, July 2026). It's built on `safaridriver` for isolated debugging sessions. safari-mcp drives the **real Safari you're already logged into** โ€” on stable Safari, with 97 tools. See the full comparison below.

---

## Highlights

- **97 tools** โ€” navigation, clicks, forms, screenshots, network, storage, accessibility, and more
- **Zero heat** โ€” native WebKit on Apple Silicon, ~60% less CPU than Chrome
- **Your real browser** โ€” keeps all logins, cookies, sessions (Gmail, GitHub, Ahrefs, etc.)
- **Background operation** โ€” Safari stays in the background, no window stealing
- **No browser dependencies** โ€” no Puppeteer, no Playwright, no WebDriver, no Chrome
- **Persistent process** โ€” reuses a single osascript process (~5ms per command vs ~80ms)
- **Framework-compatible** โ€” React, Vue, Angular, Svelte form filling via native setters

---

## Quick Start

### Prerequisites

- macOS (any version with Safari)
- Node.js 18+
- Safari โ†’ Settings โ†’ Advanced โ†’ **Show features for web developers** โœ“
- Safari โ†’ Develop โ†’ **Allow JavaScript from Apple Events** โœ“

### Install (one command)

```bash
npx safari-mcp
```

That's it โ€” no global install needed. Or install permanently:

```bash
npm install -g safari-mcp
```

### Configure your MCP client

All clients run Safari MCP the same way โ€” `npx safari-mcp`. Pick your editor:

Claude Code

```bash
claude mcp add safari -- npx safari-mcp
```

Or edit `~/.mcp.json`:

```json
{
"mcpServers": {
"safari": {
"command": "npx",
"args": ["safari-mcp"]
}
}
}
```

Claude Desktop

Edit `~/Library/Application Support/Claude/claude_desktop_config.json`:

```json
{
"mcpServers": {
"safari": {
"command": "npx",
"args": ["safari-mcp"]
}
}
}
```

Restart Claude Desktop after saving.

Cursor

One-click: [**Install in Cursor**](cursor://anysphere.cursor-deeplink/mcp/install?name=safari-mcp&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22safari-mcp%22%5D%7D)

Or edit `.cursor/mcp.json` in your project:

```json
{
"mcpServers": {
"safari": {
"command": "npx",
"args": ["safari-mcp"]
}
}
}
```

VS Code / VS Code Insiders

One-click: [**Install in VS Code**](vscode:mcp/install?%7B%22safari-mcp%22%3A%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22safari-mcp%22%5D%7D%7D)

Or edit `.vscode/mcp.json`:

```json
{
"servers": {
"safari": {
"type": "stdio",
"command": "npx",
"args": ["safari-mcp"]
}
}
}
```

Windsurf

Edit `.windsurf/mcp.json` in your project (or `~/.codeium/windsurf/mcp_config.json` globally):

```json
{
"mcpServers": {
"safari": {
"command": "npx",
"args": ["safari-mcp"]
}
}
}
```

Cline

Open Cline in VS Code โ†’ click the MCP icon โ†’ **Edit MCP Settings** โ†’ add:

```json
{
"mcpServers": {
"safari": {
"command": "npx",
"args": ["safari-mcp"]
}
}
}
```

Continue

Edit `~/.continue/config.yaml` (or `.continue/config.yaml` in workspace):

```yaml
mcpServers:
- name: safari
command: npx
args:
- safari-mcp
```

Goose

Edit `~/.config/goose/config.yaml`:

```yaml
extensions:
safari:
name: safari
type: stdio
cmd: npx
args:
- safari-mcp
enabled: true
```

LM Studio

Open LM Studio โ†’ **Settings** โ†’ **MCP Servers** โ†’ **Add Server**:

- **Name:** `safari`
- **Command:** `npx`
- **Args:** `safari-mcp`

Zed

Open Zed โ†’ **Settings** โ†’ search for "Context Servers" and add:

```json
{
"context_servers": {
"safari": {
"command": {
"path": "npx",
"args": ["safari-mcp"]
}
}
}
}
```

Alternative: Homebrew

```bash
brew install achiya-automation/tap/safari-mcp
```

Alternative: from source

```bash
git clone https://github.com/achiya-automation/safari-mcp.git
cd safari-mcp && npm install
```

---

## Usage Workflow

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.

---

## Tools (97)

Click to expand the full tool list โ€” organized by category

### Navigation (4)
| Tool | Description |
|------|-------------|
| `safari_navigate` | Navigate to URL (auto HTTPS, wait for load) |
| `safari_go_back` | Go back in history |
| `safari_go_forward` | Go forward in history |
| `safari_reload` | Reload page (optional hard reload) |

### Page Reading (3)
| Tool | Description |
|------|-------------|
| `safari_read_page` | Get title, URL, and text content |
| `safari_get_source` | Get full HTML source |
| `safari_navigate_and_read` | Navigate + read in one call |

### Click & Interaction (6)
| Tool | Description |
|------|-------------|
| `safari_click` | Click by CSS selector, visible text, or coordinates |
| `safari_double_click` | Double-click (select word, etc.) |
| `safari_right_click` | Right-click (context menu) |
| `safari_hover` | Hover over element |
| `safari_click_and_wait` | Click + wait for navigation |
| `safari_click_and_read` | Click then return the updated page โ€” saves a round-trip (React Router + full loads) |

### Form Input (11)
| Tool | Description |
|------|-------------|
| `safari_fill` | Fill input (React/Vue/Angular compatible) |
| `safari_clear_field` | Clear input field |
| `safari_select_option` | Select dropdown option |
| `safari_fill_form` | Batch fill multiple fields |
| `safari_fill_and_submit` | Fill form + submit in one call |
| `safari_type_text` | Type real keystrokes (JS-based, no System Events) |
| `safari_press_key` | Press key with modifiers |
| `safari_react_select_set` | Set a react-select v5 value via React fiber โ€” bypasses the menu UI |
| `safari_react_select_list_options` | List a react-select v5 dropdown's options without opening it |
| `safari_replace_editor` | Replace all content in a code editor (Monaco, CodeMirror, Ace, ProseMirror) |
| `safari_verify_state` | Verify an editor's framework-level state matches expected โ€” catch stale DOM before Submit |

### Screenshots & PDF (3)
| 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 |

### Scroll (3)
| Tool | Description |
|------|-------------|
| `safari_scroll` | Scroll up/down by pixels |
| `safari_scroll_to` | Scroll to exact position |
| `safari_scroll_to_element` | Smooth scroll to element |

### Tab Management (5)
| Tool | Description |
|------|-------------|
| `safari_list_tabs` | List all tabs (index, title, URL) |
| `safari_new_tab` | Open new tab (background, no focus steal) |
| `safari_close_tab` | Close tab |
| `safari_switch_tab` | Switch to tab by index |
| `safari_wait_for_new_tab` | Wait for a new tab (e.g. OAuth popup) and auto-switch to it |

### Wait (2)
| Tool | Description |
|------|-------------|
| `safari_wait_for` | Wait for element, text, or URL change |
| `safari_wait` | Wait for specified milliseconds |

### JavaScript (1)
| Tool | Description |
|------|-------------|
| `safari_evaluate` | Execute arbitrary JavaScript, return result |
| `safari_eval_file` | Execute JavaScript read from a file path (avoids huge inline scripts) |

### Element Inspection (4)
| Tool | Description |
|------|-------------|
| `safari_get_element` | Element details (tag, rect, attrs, visibility) |
| `safari_query_all` | Find all matching elements |
| `safari_get_computed_style` | Computed CSS styles |
| `safari_detect_forms` | Auto-detect all forms with field selectors |

### Accessibility (2)
| Tool | Description |
|------|-------------|
| `safari_accessibility_snapshot` | Full a11y tree: roles, ARIA, focusable elements |
| `safari_snapshot` | Accessibility tree with ref IDs for every interactive element โ€” preferred way to see page state |

### Drag & Drop (1)
| Tool | Description |
|------|-------------|
| `safari_drag` | Drag between elements or coordinates |

### File Operations (2)
| Tool | Description |
|------|-------------|
| `safari_upload_file` | Upload file via JS DataTransfer (no file dialog!) |
| `safari_paste_image` | Paste image into editor (no clipboard touch!) |

### Dialog & Window (2)
| Tool | Description |
|------|-------------|
| `safari_handle_dialog` | Handle alert/confirm/prompt |
| `safari_resize` | Resize browser window |

### Device Emulation (2)
| Tool | Description |
|------|-------------|
| `safari_emulate` | Emulate device (iPhone, iPad, Pixel, Galaxy) |
| `safari_reset_emulation` | Reset to desktop |

### Cookies & Storage (11)
| Tool | Description |
|------|-------------|
| `safari_get_cookies` | Get all cookies |
| `safari_set_cookie` | Set cookie with all options |
| `safari_delete_cookies` | Delete one or all cookies |
| `safari_local_storage` | Read localStorage |
| `safari_set_local_storage` | Write localStorage |
| `safari_delete_local_storage` | Delete/clear localStorage |
| `safari_session_storage` | Read sessionStorage |
| `safari_set_session_storage` | Write sessionStorage |
| `safari_delete_session_storage` | Delete/clear sessionStorage |
| `safari_export_storage` | Export all storage as JSON (backup/restore sessions) |
| `safari_import_storage` | Import storage state from JSON |

### Clipboard (2)
| Tool | Description |
|------|-------------|
| `safari_clipboard_read` | Read clipboard text |
| `safari_clipboard_write` | Write text to clipboard |

### Network (6)
| Tool | Description |
|------|-------------|
| `safari_network` | Quick network requests via Performance API |
| `safari_start_network_capture` | Start detailed capture (fetch + XHR) |
| `safari_network_details` | Get captured requests with headers/timing |
| `safari_clear_network` | Clear captured requests |
| `safari_mock_route` | Mock network responses (intercept fetch/XHR) |
| `safari_clear_mocks` | Remove all network mocks |

### Console (4)
| Tool | Description |
|------|-------------|
| `safari_start_console` | Start capturing console messages |
| `safari_get_console` | Get all captured messages |
| `safari_clear_console` | Clear captured messages |
| `safari_console_filter` | Filter by level (log/warn/error) |

### Performance (2)
| Tool | Description |
|------|-------------|
| `safari_performance_metrics` | Navigation timing, Web Vitals, memory |
| `safari_throttle_network` | Simulate slow-3g/fast-3g/4g/offline |

### Data Extraction (4)
| Tool | Description |
|------|-------------|
| `safari_extract_tables` | Tables as structured JSON |
| `safari_extract_meta` | All meta: OG, Twitter, JSON-LD, canonical |
| `safari_extract_images` | Images with dimensions and loading info |
| `safari_extract_links` | Links with rel, external/nofollow detection |

### Advanced (7)
| Tool | Description |
|------|-------------|
| `safari_override_geolocation` | Override browser geolocation |
| `safari_list_indexed_dbs` | List IndexedDB databases |
| `safari_get_indexed_db` | Read IndexedDB records |
| `safari_css_coverage` | Find unused CSS rules |
| `safari_analyze_page` | Full page analysis in one call |
| `safari_doctor` | Diagnose the macOS permission + daemon chain (Apple Events, Accessibility, Screen Recording, codesign) with per-failure fixes |
| `safari_reload_extension` | Hot-reload the Safari MCP Bridge extension without a manual toggle |

### Automation (1)
| Tool | Description |
|------|-------------|
| `safari_run_script` | Run multiple actions in a single call (batch) |

### Native Input โ€” CGEvent (4)
| Tool | Description |
|------|-------------|
| `safari_native_click` | OS-level mouse click (CGEvent, `isTrusted: true`) โ€” bypasses WAF/bot detection when `safari_click` is blocked (405/403) |
| `safari_native_hover` | OS-level cursor hover โ€” triggers real `:hover`/`mouseenter` for tooltips and obfuscated UIs |
| `safari_native_type` | Insert text via the real paste pipeline โ€” ProseMirror/Slate/Draft.js process it natively so Submit sends real data |
| `safari_native_keyboard` | OS-level keypress + modifiers to Safari, no focus steal โ€” reaches React trust-gated handlers (Discord/Slack send) |

### iOS & WebKit Validation (4)
| Tool | Description |
|------|-------------|
| `safari_inspect_viewport` | Validate the `` tag for iOS Safari (device-width, zoom/WCAG, viewport-fit) |
| `safari_safe_area_insets` | Read live safe-area-inset values + viewport-fit / `env()` usage (notch / Dynamic Island) |
| `safari_check_pwa` | Audit iOS "Add to Home Screen" / PWA readiness (apple-touch-icon, manifest, theme-color, splash) |
| `safari_webkit_compat` | Check page CSS against this Safari via `CSS.supports()` โ€” unsupported props, missing `-webkit-` prefixes, known quirks |

---

## Security

Safari MCP runs locally on your Mac with minimal attack surface:

| Aspect | Detail |
|--------|--------|
| Network | **No remote connections** โ€” all communication is local (stdio + localhost) |
| Permissions | macOS system permissions required (Screen Recording for screenshots) |
| Data | No telemetry, no analytics, no data sent anywhere |
| Extension | Communicates only with `localhost:9224`, validated by Safari |
| Code | Fully open source (MIT) โ€” audit every line |

---

## Safari MCP vs Alternatives

| 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.

### vs Apple's Official Safari MCP (safaridriver)

In Safari Technology Preview 247 (July 2026), Apple shipped an **official** Safari MCP server built on `safaridriver`. 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**.

| | ๐Ÿฆ 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 only |
| **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" in STP |
| **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 STP. **For everything else โ€” daily automation on the browser you're already signed into, on stable Safari โ€” safari-mcp is built for exactly that.**

### Why Safari MCP and Not the Other Safari MCP Projects?

There are several "safari-mcp" projects floating around. Here's how they compare:

| Feature | **๐Ÿฆ safari-mcp** *(this repo)* | [lxman/safari-mcp-server](https://github.com/lxman/safari-mcp-server) | [Epistates/MCPSafari](https://github.com/Epistates/MCPSafari) | [HayoDev/safari-devtools-mcp](https://github.com/HayoDev/safari-devtools-mcp) |
|---------|:------------------------------:|:----------------------:|:------------:|:----------------------:|
| **Tools** | **97** | ~10 | 23 | ~15 |
| **Install** | `npx safari-mcp` | Manual | Binary | `npx` |
| **Engine** | **Dual** (Extension + AppleScript) | WebDriver | Extension only | DevTools Protocol |
| **Keeps your real Safari logins** | โœ… Yes | โš ๏ธ Limited | โœ… Yes | โŒ Debug session |
| **Background (no focus steal)** | โœ… Yes | โŒ No | โš ๏ธ Sometimes | โœ… Yes |
| **Storage tools** (cookies, localStorage, IndexedDB) | **10** | 0 | 0 | 2 |
| **Data extraction** (tables, meta, images, links) | **4** | 0 | 0 | 0 |
| **Network mocking** | โœ… Yes | โŒ No | โŒ No | โŒ No |
| **Device emulation** (iPhone, iPad, Pixel) | โœ… Yes | โŒ No | โŒ No | โŒ No |
| **File upload** (no dialog) | โœ… JS DataTransfer | โŒ No | โŒ No | โŒ No |
| **Image paste** (no clipboard touch) | โœ… Yes | โŒ No | โŒ No | โŒ No |
| **PDF export** | โœ… Yes | โŒ No | โŒ No | โŒ No |
| **Console capture** | **4 tools** | 0 | 1 | 1 |
| **Performance metrics + Web Vitals** | โœ… Yes | โŒ No | โŒ No | โš ๏ธ Partial |
| **Active maintenance** | โœ… Multiple releases/week | ๐ŸŸก Sporadic | ๐ŸŸก Slow | ๐ŸŸก Slow |
| **License** | **MIT** | MIT | None specified | MIT |
| **In MCP Registry** | โœ… | โŒ | โŒ | โœ… |
| **In Awesome MCP** | โœ… | โŒ | โŒ | โŒ |

> **TL;DR** โ€” if you want the most complete Safari MCP with the smoothest install, the most tools, and active maintenance, **this is the one**.

---

## Architecture

Safari MCP uses a **dual-engine** architecture โ€” the Extension is preferred for speed and advanced capabilities, with AppleScript as an always-available fallback:

```
Claude/Cursor/AI Agent
โ†“ MCP Protocol (stdio)
Safari MCP Server (Node.js)
โ†“ โ†“
Extension (HTTP) AppleScript + Swift daemon
(~5-20ms/cmd) (~5ms/cmd, always available)
โ†“ โ†“
Content Script do JavaScript in tab N
โ†“ โ†“
Page DOM โ†โ†โ†โ†โ†โ†โ†โ†โ†โ† Page DOM
```

**Key design decisions:**
- **Dual engine with automatic fallback** โ€” Extension is preferred; if not connected, AppleScript handles everything seamlessly
- **Persistent Swift helper** โ€” one long-running process instead of spawning per command (16x faster)
- **Tab-indexed operations** โ€” all JS runs on a specific tab by index, never steals visual focus
- **JS-first approach** โ€” typing, clicking, file upload all use JavaScript events (no System Events keyboard conflicts)
- **No `activate`** โ€” Safari is never brought to foreground

---

## Safari Extension (Optional)

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:

### What the Extension Adds

| 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).

### Installing the Extension

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](https://github.com/achiya-automation/safari-mcp) to build from source.

**Prerequisites:** Xcode (install from App Store โ€” free)

```bash
# 1. Clone the repo (the npm package does not include the Xcode project)
git clone https://github.com/achiya-automation/safari-mcp.git
cd safari-mcp

# 2. Build the extension
xcodebuild -project "xcode/Safari MCP/Safari MCP.xcodeproj" \
-scheme "Safari MCP (macOS)" -configuration Release build

# 3. Ad-hoc sign the built app so Safari will load it
# (xcodebuild without a signing identity produces a bundle Safari silently rejects)
APP_PATH=$(find ~/Library/Developer/Xcode/DerivedData/Safari_MCP-*/Build/Products/Release -name "Safari MCP.app" -maxdepth 2 | head -1)
codesign --sign - --force --deep "$APP_PATH"

# 4. Re-sign safari-helper with the Apple Events entitlement
# (helps macOS surface the TCC Automation prompt reliably)
codesign --sign - --force --entitlements safari-helper.entitlements safari-helper

# 4. Open the app (needed once so Safari registers the extension)
open "$APP_PATH"
```

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 MCP server on port `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

---

## macOS Permissions

Safari MCP needs these one-time permissions:

| Permission | Where | Why |
|-----------|-------|-----|
| JavaScript from Apple Events | Safari โ†’ Develop menu | Required for `do JavaScript` |
| Automation โ†’ Safari | System Settings โ†’ Privacy & Security โ†’ Automation | Required for all AppleScript-backed tools |
| Screen Recording | System Settings โ†’ Privacy & Security โ†’ Screen Recording | Required for `safari_screenshot` |
| Accessibility (safari-helper) | System Settings โ†’ Privacy & Security โ†’ Accessibility | Required for `safari_native_click`, `safari_native_keyboard`, `safari_native_hover` and `safari_save_pdf` |

### Granting Accessibility to safari-helper (required for `safari_native_*`)

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.

### Granting Automation โ†’ Safari (important for IDE users)

macOS TCC grants Automation permission to the **parent process** that spawns the MCP server, not to `safari-mcp` itself. So you need to grant **Automation โ†’ Safari** to the app that runs Claude Code / Cursor / Windsurf โ€” typically **Visual Studio Code** or **Terminal**.

If the permission dialog never appears automatically, run this command once from a Terminal that already has Automation permission:

```bash
osascript -e 'tell application "Safari" to get URL of current tab of window 1'
```

That call registers the Terminal app in the Automation database and then triggers the prompt for Safari. After you approve it, subsequent MCP calls from any child process chain will work.

---

## Troubleshooting

| 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 |

---

## Works With

Safari MCP works with any MCP-compatible client:

| Client | Status |
|--------|--------|
| [Claude Code](https://claude.ai/claude-code) | โœ… Tested daily |
| [Claude Desktop](https://claude.ai/download) | โœ… Tested |
| [Cursor](https://cursor.sh) | โœ… Tested |
| [Windsurf](https://codeium.com/windsurf) | โœ… Compatible |
| [VS Code + Continue](https://continue.dev) | โœ… Compatible |

---

## Contributing

PRs welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for setup instructions.

The codebase is two files:
- `safari.js` โ€” Safari automation layer (AppleScript + JavaScript)
- `index.js` โ€” MCP server with tool definitions

---

## Sponsors

Safari MCP is free and open source. If it saves you time or CPU cycles, consider supporting its development:

Sponsor via PayPal

Your support funds:
- ๐Ÿงช Testing across macOS versions and Safari releases
- ๐Ÿ› ๏ธ New tools and features
- ๐Ÿ“– Documentation and examples

[Become the first sponsor!](https://paypal.me/achiyaC123)

---

## Commercial Support

**Need Safari MCP integrated into your product or agent stack?** [Achiya Automation](https://achiya-automation.com/en/blog/safari-mcp-browser-automation/) offers:

- **Priority bug fixes** and custom tool development for your use case
- **Integration consulting** โ€” wiring Safari MCP into production agent systems (Claude, Cursor, n8n, custom)
- **Private deployment support** โ€” multi-user Safari MCP, non-standard macOS environments, CI/CD
- **Training workshops** for engineering teams adopting MCP-based automation

Built by the author of Safari MCP. [Start a conversation โ†’](https://achiya-automation.com/en/contact/)

---

## What agents unlock with Safari MCP

When an AI agent drives Safari MCP, it gets things a headless browser can't:

- **Real authenticated sessions** โ€” Gmail, GitHub, Ahrefs, Slack, banking dashboards are all already logged in
- **Framework-aware form filling** โ€” `safari_fill_and_submit` calls React/Vue/Angular setters natively, no guessing whether `input` events fired
- **Background operation** โ€” the agent works in parallel while you keep using your Mac
- **One MCP call per workflow** โ€” `safari_run_script` batches navigation + clicks + extraction into a single roundtrip

The pattern holds across models: **drive the browser the human already trusts** โ€” you inherit logins, cookies, extensions, and the user's exact environment in one step.

---

## Community

**6,000+ monthly npm downloads** โ€” developers are building AI agents on macOS with Safari MCP.

- [GitHub Discussions](https://github.com/achiya-automation/safari-mcp/discussions) โ€” ask questions, share use cases
- [Issues](https://github.com/achiya-automation/safari-mcp/issues) โ€” bug reports and feature requests
- [![Good First Issues](https://img.shields.io/github/issues/achiya-automation/safari-mcp/good%20first%20issue?color=7057ff&label=good%20first%20issues)](https://github.com/achiya-automation/safari-mcp/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) โ€” start contributing

---

## Ecosystem

Other macOS MCP servers that complement Safari MCP:

| Project | What it does | When to use |
|---------|-------------|-------------|
| [mcp-server-macos-use](https://github.com/mediar-ai/mcp-server-macos-use) | OS-level macOS automation (accessibility, screen control) | System-wide interactions beyond Safari |
| [chrome-devtools-mcp](https://github.com/anthropics/chrome-devtools-mcp) | Chrome DevTools Protocol | Lighthouse audits, Chrome-specific performance traces |

> Using Safari MCP alongside Chrome DevTools MCP? Safari handles 95% of daily browsing (zero overhead), Chrome handles the 5% that needs Lighthouse or Chrome-specific traces.

---

## Like it? Give it a โญ

If Safari MCP saves you from Chrome overhead, **a star helps others discover it:**

[![Star this repo](https://img.shields.io/github/stars/achiya-automation/safari-mcp?style=social)](https://github.com/achiya-automation/safari-mcp)

[Share on Twitter/X](https://twitter.com/intent/tweet?text=Safari%20MCP%20%E2%80%94%20Stop%20running%20Chrome%20just%20so%20your%20AI%20agent%20can%20browse.%2096%20tools%2C%20native%20Safari%2C%2060%25%20less%20CPU.&url=https%3A%2F%2Fgithub.com%2Fachiya-automation%2Fsafari-mcp) ยท [Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fgithub.com%2Fachiya-automation%2Fsafari-mcp) ยท [Write about it](https://dev.to/)

[![Star History Chart](https://api.star-history.com/svg?repos=achiya-automation/safari-mcp&type=Date)](https://star-history.com/#achiya-automation/safari-mcp&Date)

---

## Listed On

[![Glama](https://glama.ai/mcp/servers/achiya-automation/safari-mcp/badges/score.svg)](https://glama.ai/mcp/servers/achiya-automation/safari-mcp) [![MCP Registry](https://img.shields.io/badge/MCP-Registry-purple)](https://registry.modelcontextprotocol.io/) [![MCP Scoreboard](https://mcpscoreboard.com/badge/05977769-8762-4e89-aff3-a0c5776843bb.svg)](https://mcpscoreboard.com/server/05977769-8762-4e89-aff3-a0c5776843bb/) [![CI](https://github.com/achiya-automation/safari-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/achiya-automation/safari-mcp/actions/workflows/ci.yml)

---

## License

MIT โ€” use it however you want.