The browser for your coding agent. Your real Safari, logged in — no Chrome, no heat, no headless. 97 tools · No Chrome/Puppeteer/Playwright needed · ~5ms per command · 60% less CPU than Chrome Quick Start · All 97 Tools · Examples · Why Safari MCP? · Architecture · Changelog Your AI agent needs to browse. So it either: - Spins up Chromium via Playwright — with no logins, no cookies, no sessions -
npx mdskills install achiya-automation/safari-mcp@achiya-automation? Sign in with GitHub to claim this listing.Comprehensive Safari automation with 97 tools, excellent docs, and clear setup for AI agents on macOS
1<div align="center">23<img src="social-preview.png" alt="Safari MCP Server — 97 native browser automation tools for AI agents on macOS" width="100%">45<br/>67# 🦁 Safari MCP89**The browser for your coding agent.**1011*Your real Safari, logged in — no Chrome, no heat, no headless.*1213[](https://www.npmjs.com/package/safari-mcp)14[](https://www.npmjs.com/package/safari-mcp)15[](https://opensource.org/licenses/MIT)16[](https://www.apple.com/macos/)1718[](https://glama.ai/mcp/servers/@achiya-automation/safari-mcp)19[](https://registry.modelcontextprotocol.io/v0/servers?search=achiya-automation)20[](https://smithery.ai/server/@achiya-automation/safari-mcp)21[](https://mcpscoreboard.com/server/05977769-8762-4e89-aff3-a0c5776843bb/)2223<a href="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"><img src="https://img.shields.io/badge/VS_Code-Install_Server-0078d4?logo=visual-studio-code&logoColor=white" alt="Install in VS Code"></a>24<a href="https://insiders.vscode.dev/redirect?url=vscode-insiders:mcp/install?%7B%22safari-mcp%22%3A%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22safari-mcp%22%5D%7D%7D"><img src="https://img.shields.io/badge/VS_Code_Insiders-Install_Server-24bfa5?logo=visual-studio-code&logoColor=white" alt="Install in VS Code Insiders"></a>25<a href="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"><img src="https://img.shields.io/badge/Cursor-Install_Server-f97316?logo=cursor&logoColor=white" alt="Install in Cursor"></a>2627**97 tools** · **No Chrome/Puppeteer/Playwright needed** · **~5ms per command** · **60% less CPU than Chrome**2829[Quick Start](#quick-start) · [All 97 Tools](#tools-97) · [Examples](examples/) · [Why Safari MCP?](#safari-mcp-vs-alternatives) · [Architecture](#architecture) · [Changelog](CHANGELOG.md)30313233</div>3435## ❌ Without Safari MCP3637Your AI agent needs to browse. So it either:3839- **Spins up Chromium via Playwright** — with no logins, no cookies, no sessions40- **Uses Chrome DevTools MCP** — and melts your fan running a second browser41- **Relies on headless scrapers** — blocked by Cloudflare, reCAPTCHA, and bot detection4243## ✅ With Safari MCP4445Your AI drives the **Safari you're already logged into** — Gmail, GitHub, Ahrefs, Slack, banking.4647Native WebKit. ~60% less CPU. Background operation. 97 tools. One `npx` command. macOS only.4849> 📰 **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)5051> 🍎 **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.5253---5455## Highlights5657- **97 tools** — navigation, clicks, forms, screenshots, network, storage, accessibility, and more58- **Zero heat** — native WebKit on Apple Silicon, ~60% less CPU than Chrome59- **Your real browser** — keeps all logins, cookies, sessions (Gmail, GitHub, Ahrefs, etc.)60- **Background operation** — Safari stays in the background, no window stealing61- **No browser dependencies** — no Puppeteer, no Playwright, no WebDriver, no Chrome62- **Persistent process** — reuses a single osascript process (~5ms per command vs ~80ms)63- **Framework-compatible** — React, Vue, Angular, Svelte form filling via native setters6465---6667## Quick Start6869### Prerequisites7071- macOS (any version with Safari)72- Node.js 18+73- Safari → Settings → Advanced → **Show features for web developers** ✓74- Safari → Develop → **Allow JavaScript from Apple Events** ✓7576### Install (one command)7778```bash79npx safari-mcp80```8182That's it — no global install needed. Or install permanently:8384```bash85npm install -g safari-mcp86```8788### Configure your MCP client8990All clients run Safari MCP the same way — `npx safari-mcp`. Pick your editor:9192<details>93<summary><b>Claude Code</b></summary>9495```bash96claude mcp add safari -- npx safari-mcp97```9899Or edit `~/.mcp.json`:100101```json102{103 "mcpServers": {104 "safari": {105 "command": "npx",106 "args": ["safari-mcp"]107 }108 }109}110```111</details>112113<details>114<summary><b>Claude Desktop</b></summary>115116Edit `~/Library/Application Support/Claude/claude_desktop_config.json`:117118```json119{120 "mcpServers": {121 "safari": {122 "command": "npx",123 "args": ["safari-mcp"]124 }125 }126}127```128129Restart Claude Desktop after saving.130</details>131132<details>133<summary><b>Cursor</b></summary>134135One-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)136137Or edit `.cursor/mcp.json` in your project:138139```json140{141 "mcpServers": {142 "safari": {143 "command": "npx",144 "args": ["safari-mcp"]145 }146 }147}148```149</details>150151<details>152<summary><b>VS Code / VS Code Insiders</b></summary>153154One-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)155156Or edit `.vscode/mcp.json`:157158```json159{160 "servers": {161 "safari": {162 "type": "stdio",163 "command": "npx",164 "args": ["safari-mcp"]165 }166 }167}168```169</details>170171<details>172<summary><b>Windsurf</b></summary>173174Edit `.windsurf/mcp.json` in your project (or `~/.codeium/windsurf/mcp_config.json` globally):175176```json177{178 "mcpServers": {179 "safari": {180 "command": "npx",181 "args": ["safari-mcp"]182 }183 }184}185```186</details>187188<details>189<summary><b>Cline</b></summary>190191Open Cline in VS Code → click the MCP icon → **Edit MCP Settings** → add:192193```json194{195 "mcpServers": {196 "safari": {197 "command": "npx",198 "args": ["safari-mcp"]199 }200 }201}202```203</details>204205<details>206<summary><b>Continue</b></summary>207208Edit `~/.continue/config.yaml` (or `.continue/config.yaml` in workspace):209210```yaml211mcpServers:212 - name: safari213 command: npx214 args:215 - safari-mcp216```217</details>218219<details>220<summary><b>Goose</b></summary>221222Edit `~/.config/goose/config.yaml`:223224```yaml225extensions:226 safari:227 name: safari228 type: stdio229 cmd: npx230 args:231 - safari-mcp232 enabled: true233```234</details>235236<details>237<summary><b>LM Studio</b></summary>238239Open LM Studio → **Settings** → **MCP Servers** → **Add Server**:240241- **Name:** `safari`242- **Command:** `npx`243- **Args:** `safari-mcp`244</details>245246<details>247<summary><b>Zed</b></summary>248249Open Zed → **Settings** → search for "Context Servers" and add:250251```json252{253 "context_servers": {254 "safari": {255 "command": {256 "path": "npx",257 "args": ["safari-mcp"]258 }259 }260 }261}262```263</details>264265<details>266<summary><b>Alternative: Homebrew</b></summary>267268```bash269brew install achiya-automation/tap/safari-mcp270```271</details>272273<details>274<summary><b>Alternative: from source</b></summary>275276```bash277git clone https://github.com/achiya-automation/safari-mcp.git278cd safari-mcp && npm install279```280</details>281282---283284## Usage Workflow285286The recommended pattern for AI agents using Safari MCP:287288```2891. safari_snapshot → Get page state (accessibility tree)2902. safari_click/fill/... → Interact with elements by ref2913. safari_snapshot → Verify the result292```293294**Element targeting** — tools accept multiple targeting strategies:295296| Strategy | Example | Best for |297|----------|---------|----------|298| CSS selector | `#login-btn`, `.submit` | Unique elements |299| Visible text | `"Sign In"`, `"Submit"` | Buttons, links |300| Coordinates | `x: 100, y: 200` | Canvas, custom widgets |301| Ref from snapshot | `ref: "e42"` | Any element from accessibility tree |302303> **Tip:** Start with `safari_snapshot` to get element refs, then use refs for precise targeting. This is faster and more reliable than CSS selectors.304305---306307## Tools (97)308309<details>310<summary><b>Click to expand the full tool list — organized by category</b></summary>311312### Navigation (4)313| Tool | Description |314|------|-------------|315| `safari_navigate` | Navigate to URL (auto HTTPS, wait for load) |316| `safari_go_back` | Go back in history |317| `safari_go_forward` | Go forward in history |318| `safari_reload` | Reload page (optional hard reload) |319320### Page Reading (3)321| Tool | Description |322|------|-------------|323| `safari_read_page` | Get title, URL, and text content |324| `safari_get_source` | Get full HTML source |325| `safari_navigate_and_read` | Navigate + read in one call |326327### Click & Interaction (6)328| Tool | Description |329|------|-------------|330| `safari_click` | Click by CSS selector, visible text, or coordinates |331| `safari_double_click` | Double-click (select word, etc.) |332| `safari_right_click` | Right-click (context menu) |333| `safari_hover` | Hover over element |334| `safari_click_and_wait` | Click + wait for navigation |335| `safari_click_and_read` | Click then return the updated page — saves a round-trip (React Router + full loads) |336337### Form Input (11)338| Tool | Description |339|------|-------------|340| `safari_fill` | Fill input (React/Vue/Angular compatible) |341| `safari_clear_field` | Clear input field |342| `safari_select_option` | Select dropdown option |343| `safari_fill_form` | Batch fill multiple fields |344| `safari_fill_and_submit` | Fill form + submit in one call |345| `safari_type_text` | Type real keystrokes (JS-based, no System Events) |346| `safari_press_key` | Press key with modifiers |347| `safari_react_select_set` | Set a react-select v5 value via React fiber — bypasses the menu UI |348| `safari_react_select_list_options` | List a react-select v5 dropdown's options without opening it |349| `safari_replace_editor` | Replace all content in a code editor (Monaco, CodeMirror, Ace, ProseMirror) |350| `safari_verify_state` | Verify an editor's framework-level state matches expected — catch stale DOM before Submit |351352### Screenshots & PDF (3)353| Tool | Description |354|------|-------------|355| `safari_screenshot` | Screenshot as PNG (viewport or full page) |356| `safari_screenshot_element` | Screenshot a specific element |357| `safari_save_pdf` | Export page as PDF |358359### Scroll (3)360| Tool | Description |361|------|-------------|362| `safari_scroll` | Scroll up/down by pixels |363| `safari_scroll_to` | Scroll to exact position |364| `safari_scroll_to_element` | Smooth scroll to element |365366### Tab Management (5)367| Tool | Description |368|------|-------------|369| `safari_list_tabs` | List all tabs (index, title, URL) |370| `safari_new_tab` | Open new tab (background, no focus steal) |371| `safari_close_tab` | Close tab |372| `safari_switch_tab` | Switch to tab by index |373| `safari_wait_for_new_tab` | Wait for a new tab (e.g. OAuth popup) and auto-switch to it |374375### Wait (2)376| Tool | Description |377|------|-------------|378| `safari_wait_for` | Wait for element, text, or URL change |379| `safari_wait` | Wait for specified milliseconds |380381### JavaScript (1)382| Tool | Description |383|------|-------------|384| `safari_evaluate` | Execute arbitrary JavaScript, return result |385| `safari_eval_file` | Execute JavaScript read from a file path (avoids huge inline scripts) |386387### Element Inspection (4)388| Tool | Description |389|------|-------------|390| `safari_get_element` | Element details (tag, rect, attrs, visibility) |391| `safari_query_all` | Find all matching elements |392| `safari_get_computed_style` | Computed CSS styles |393| `safari_detect_forms` | Auto-detect all forms with field selectors |394395### Accessibility (2)396| Tool | Description |397|------|-------------|398| `safari_accessibility_snapshot` | Full a11y tree: roles, ARIA, focusable elements |399| `safari_snapshot` | Accessibility tree with ref IDs for every interactive element — preferred way to see page state |400401### Drag & Drop (1)402| Tool | Description |403|------|-------------|404| `safari_drag` | Drag between elements or coordinates |405406### File Operations (2)407| Tool | Description |408|------|-------------|409| `safari_upload_file` | Upload file via JS DataTransfer (no file dialog!) |410| `safari_paste_image` | Paste image into editor (no clipboard touch!) |411412### Dialog & Window (2)413| Tool | Description |414|------|-------------|415| `safari_handle_dialog` | Handle alert/confirm/prompt |416| `safari_resize` | Resize browser window |417418### Device Emulation (2)419| Tool | Description |420|------|-------------|421| `safari_emulate` | Emulate device (iPhone, iPad, Pixel, Galaxy) |422| `safari_reset_emulation` | Reset to desktop |423424### Cookies & Storage (11)425| Tool | Description |426|------|-------------|427| `safari_get_cookies` | Get all cookies |428| `safari_set_cookie` | Set cookie with all options |429| `safari_delete_cookies` | Delete one or all cookies |430| `safari_local_storage` | Read localStorage |431| `safari_set_local_storage` | Write localStorage |432| `safari_delete_local_storage` | Delete/clear localStorage |433| `safari_session_storage` | Read sessionStorage |434| `safari_set_session_storage` | Write sessionStorage |435| `safari_delete_session_storage` | Delete/clear sessionStorage |436| `safari_export_storage` | Export all storage as JSON (backup/restore sessions) |437| `safari_import_storage` | Import storage state from JSON |438439### Clipboard (2)440| Tool | Description |441|------|-------------|442| `safari_clipboard_read` | Read clipboard text |443| `safari_clipboard_write` | Write text to clipboard |444445### Network (6)446| Tool | Description |447|------|-------------|448| `safari_network` | Quick network requests via Performance API |449| `safari_start_network_capture` | Start detailed capture (fetch + XHR) |450| `safari_network_details` | Get captured requests with headers/timing |451| `safari_clear_network` | Clear captured requests |452| `safari_mock_route` | Mock network responses (intercept fetch/XHR) |453| `safari_clear_mocks` | Remove all network mocks |454455### Console (4)456| Tool | Description |457|------|-------------|458| `safari_start_console` | Start capturing console messages |459| `safari_get_console` | Get all captured messages |460| `safari_clear_console` | Clear captured messages |461| `safari_console_filter` | Filter by level (log/warn/error) |462463### Performance (2)464| Tool | Description |465|------|-------------|466| `safari_performance_metrics` | Navigation timing, Web Vitals, memory |467| `safari_throttle_network` | Simulate slow-3g/fast-3g/4g/offline |468469### Data Extraction (4)470| Tool | Description |471|------|-------------|472| `safari_extract_tables` | Tables as structured JSON |473| `safari_extract_meta` | All meta: OG, Twitter, JSON-LD, canonical |474| `safari_extract_images` | Images with dimensions and loading info |475| `safari_extract_links` | Links with rel, external/nofollow detection |476477### Advanced (7)478| Tool | Description |479|------|-------------|480| `safari_override_geolocation` | Override browser geolocation |481| `safari_list_indexed_dbs` | List IndexedDB databases |482| `safari_get_indexed_db` | Read IndexedDB records |483| `safari_css_coverage` | Find unused CSS rules |484| `safari_analyze_page` | Full page analysis in one call |485| `safari_doctor` | Diagnose the macOS permission + daemon chain (Apple Events, Accessibility, Screen Recording, codesign) with per-failure fixes |486| `safari_reload_extension` | Hot-reload the Safari MCP Bridge extension without a manual toggle |487488### Automation (1)489| Tool | Description |490|------|-------------|491| `safari_run_script` | Run multiple actions in a single call (batch) |492493### Native Input — CGEvent (4)494| Tool | Description |495|------|-------------|496| `safari_native_click` | OS-level mouse click (CGEvent, `isTrusted: true`) — bypasses WAF/bot detection when `safari_click` is blocked (405/403) |497| `safari_native_hover` | OS-level cursor hover — triggers real `:hover`/`mouseenter` for tooltips and obfuscated UIs |498| `safari_native_type` | Insert text via the real paste pipeline — ProseMirror/Slate/Draft.js process it natively so Submit sends real data |499| `safari_native_keyboard` | OS-level keypress + modifiers to Safari, no focus steal — reaches React trust-gated handlers (Discord/Slack send) |500501### iOS & WebKit Validation (4)502| Tool | Description |503|------|-------------|504| `safari_inspect_viewport` | Validate the `<meta name=viewport>` tag for iOS Safari (device-width, zoom/WCAG, viewport-fit) |505| `safari_safe_area_insets` | Read live safe-area-inset values + viewport-fit / `env()` usage (notch / Dynamic Island) |506| `safari_check_pwa` | Audit iOS "Add to Home Screen" / PWA readiness (apple-touch-icon, manifest, theme-color, splash) |507| `safari_webkit_compat` | Check page CSS against this Safari via `CSS.supports()` — unsupported props, missing `-webkit-` prefixes, known quirks |508509</details>510511---512513## Security514515Safari MCP runs locally on your Mac with minimal attack surface:516517| Aspect | Detail |518|--------|--------|519| Network | **No remote connections** — all communication is local (stdio + localhost) |520| Permissions | macOS system permissions required (Screen Recording for screenshots) |521| Data | No telemetry, no analytics, no data sent anywhere |522| Extension | Communicates only with `localhost:9224`, validated by Safari |523| Code | Fully open source (MIT) — audit every line |524525---526527## Safari MCP vs Alternatives528529| Feature | Safari MCP | Chrome DevTools MCP | Playwright MCP |530|---------|:----------:|:-------------------:|:--------------:|531| CPU/Heat | 🟢 Minimal | 🔴 High | 🟡 Medium |532| Your logins | ✅ Yes | ✅ Yes | ❌ No |533| macOS native | ✅ WebKit | ❌ Chromium | ❌ Chromium/WebKit |534| Browser dependencies | None | Chrome + debug port | Playwright runtime |535| Tools | 97 | ~30 | ~25 |536| File upload | JS (no dialog) | CDP | Playwright API |537| Image paste | JS (no clipboard) | CDP | Playwright API |538| Focus steal | ❌ Background | ❌ Background | ❌ Headless |539| Network mocking | ✅ | ❌ | ✅ |540| Lighthouse | ❌ | ✅ | ❌ |541| Performance trace | ❌ | ✅ | ❌ |542543> **Tip:** Use Safari MCP for daily browsing tasks (95% of work) and Chrome DevTools MCP only for Lighthouse/Performance audits.544545### vs Apple's Official Safari MCP (safaridriver)546547In 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**.548549| | 🦁 safari-mcp *(this repo)* | Apple `safaridriver --mcp` |550|---|:---:|:---:|551| **Your real logins / cookies** | ✅ Your actual Safari | ⚠️ Isolated automation session — no access to AutoFill or browsing activity |552| **Runs on** | ✅ Stable Safari, every Mac | ❌ Safari Technology Preview 247 only |553| **Background (no focus steal)** | ✅ Yes | ❌ Dedicated window with a "controlled by automation" banner |554| **Tools** | **97** | ~17 |555| **Storage** (cookies, localStorage, IndexedDB) | ✅ 10 tools | ❌ |556| **Network mocking + throttling** | ✅ Yes | ❌ Read-only network inspection |557| **Device emulation** (iPhone, iPad) | ✅ Yes | ⚠️ Viewport + media type only |558| **Setup** | `npx safari-mcp` | Enable "remote automation and external agents" in STP |559| **Official Apple support** | ❌ Community (MIT) | ✅ Apple, WebDriver-standard |560561> **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.**562563### Why Safari MCP and Not the Other Safari MCP Projects?564565There are several "safari-mcp" projects floating around. Here's how they compare:566567| 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) |568|---------|:------------------------------:|:----------------------:|:------------:|:----------------------:|569| **Tools** | **97** | ~10 | 23 | ~15 |570| **Install** | `npx safari-mcp` | Manual | Binary | `npx` |571| **Engine** | **Dual** (Extension + AppleScript) | WebDriver | Extension only | DevTools Protocol |572| **Keeps your real Safari logins** | ✅ Yes | ⚠️ Limited | ✅ Yes | ❌ Debug session |573| **Background (no focus steal)** | ✅ Yes | ❌ No | ⚠️ Sometimes | ✅ Yes |574| **Storage tools** (cookies, localStorage, IndexedDB) | **10** | 0 | 0 | 2 |575| **Data extraction** (tables, meta, images, links) | **4** | 0 | 0 | 0 |576| **Network mocking** | ✅ Yes | ❌ No | ❌ No | ❌ No |577| **Device emulation** (iPhone, iPad, Pixel) | ✅ Yes | ❌ No | ❌ No | ❌ No |578| **File upload** (no dialog) | ✅ JS DataTransfer | ❌ No | ❌ No | ❌ No |579| **Image paste** (no clipboard touch) | ✅ Yes | ❌ No | ❌ No | ❌ No |580| **PDF export** | ✅ Yes | ❌ No | ❌ No | ❌ No |581| **Console capture** | **4 tools** | 0 | 1 | 1 |582| **Performance metrics + Web Vitals** | ✅ Yes | ❌ No | ❌ No | ⚠️ Partial |583| **Active maintenance** | ✅ Multiple releases/week | 🟡 Sporadic | 🟡 Slow | 🟡 Slow |584| **License** | **MIT** | MIT | None specified | MIT |585| **In MCP Registry** | ✅ | ❌ | ❌ | ✅ |586| **In Awesome MCP** | ✅ | ❌ | ❌ | ❌ |587588> **TL;DR** — if you want the most complete Safari MCP with the smoothest install, the most tools, and active maintenance, **this is the one**.589590---591592## Architecture593594Safari MCP uses a **dual-engine** architecture — the Extension is preferred for speed and advanced capabilities, with AppleScript as an always-available fallback:595596```597Claude/Cursor/AI Agent598 ↓ MCP Protocol (stdio)599 Safari MCP Server (Node.js)600 ↓ ↓601 Extension (HTTP) AppleScript + Swift daemon602 (~5-20ms/cmd) (~5ms/cmd, always available)603 ↓ ↓604 Content Script do JavaScript in tab N605 ↓ ↓606 Page DOM ←←←←←←←←←← Page DOM607```608609**Key design decisions:**610- **Dual engine with automatic fallback** — Extension is preferred; if not connected, AppleScript handles everything seamlessly611- **Persistent Swift helper** — one long-running process instead of spawning per command (16x faster)612- **Tab-indexed operations** — all JS runs on a specific tab by index, never steals visual focus613- **JS-first approach** — typing, clicking, file upload all use JavaScript events (no System Events keyboard conflicts)614- **No `activate`** — Safari is never brought to foreground615616---617618## Safari Extension (Optional)619620The Safari MCP Extension is **optional but recommended**. Without it, ~80% of functionality works via AppleScript alone. The extension adds capabilities that AppleScript cannot provide:621622### What the Extension Adds623624| Capability | With Extension | AppleScript Only |625|-----------|:--------------:|:----------------:|626| Closed Shadow DOM (Reddit, Web Components) | ✅ Full access | ❌ Invisible |627| Strict CSP sites | ✅ Bypasses via MAIN world | ❌ Often blocked |628| React/Vue/Angular state manipulation | ✅ Deep (Fiber, ProseMirror) | ⚠️ Basic |629| Loading state detection (spinners, skeletons) | ✅ Smart detection | ❌ No |630| Dialog handling (alert/confirm) | ❌ | ✅ Only AppleScript |631| Native OS-level click (CGEvent) | ❌ | ✅ Only AppleScript |632| PDF export | ❌ | ✅ Only AppleScript |633634> **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).635636### Installing the Extension637638The extension requires a one-time build with Xcode (free, included with macOS).639640> **Note for npm users:** The `xcode/` directory is not included in the npm package.641> Clone the [GitHub repository](https://github.com/achiya-automation/safari-mcp) to build from source.642643**Prerequisites:** Xcode (install from App Store — free)644645```bash646# 1. Clone the repo (the npm package does not include the Xcode project)647git clone https://github.com/achiya-automation/safari-mcp.git648cd safari-mcp649650# 2. Build the extension651xcodebuild -project "xcode/Safari MCP/Safari MCP.xcodeproj" \652 -scheme "Safari MCP (macOS)" -configuration Release build653654# 3. Ad-hoc sign the built app so Safari will load it655# (xcodebuild without a signing identity produces a bundle Safari silently rejects)656APP_PATH=$(find ~/Library/Developer/Xcode/DerivedData/Safari_MCP-*/Build/Products/Release -name "Safari MCP.app" -maxdepth 2 | head -1)657codesign --sign - --force --deep "$APP_PATH"658659# 4. Re-sign safari-helper with the Apple Events entitlement660# (helps macOS surface the TCC Automation prompt reliably)661codesign --sign - --force --entitlements safari-helper.entitlements safari-helper662663# 4. Open the app (needed once so Safari registers the extension)664open "$APP_PATH"665```666667Alternatively, 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.668669Then in Safari:6701. Safari → Settings → Advanced → enable **Show features for web developers**6712. Safari → Develop → **Allow Unsigned Extensions** (required each Safari restart)6723. Safari → Settings → Extensions → enable **Safari MCP Bridge**673674The extension connects automatically to the MCP server on port `9224`.675676> **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.677678**Toolbar icon status:**679- **ON** — connected to MCP server680- **OFF** — manually disabled via popup681- *(no badge)* — server not running, will auto-reconnect682683---684685## macOS Permissions686687Safari MCP needs these one-time permissions:688689| Permission | Where | Why |690|-----------|-------|-----|691| JavaScript from Apple Events | Safari → Develop menu | Required for `do JavaScript` |692| Automation → Safari | System Settings → Privacy & Security → Automation | Required for all AppleScript-backed tools |693| Screen Recording | System Settings → Privacy & Security → Screen Recording | Required for `safari_screenshot` |694| Accessibility (safari-helper) | System Settings → Privacy & Security → Accessibility | Required for `safari_native_click`, `safari_native_keyboard`, `safari_native_hover` and `safari_save_pdf` |695696### Granting Accessibility to safari-helper (required for `safari_native_*`)697698The `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.6997001. Open **System Settings → Privacy & Security → Accessibility**.7012. Click `+` (unlock with your password if needed).7023. Navigate to the helper binary and add it:703 - npm global install: `$(npm root -g)/safari-mcp/safari-helper`704 - npx / project install: `./node_modules/safari-mcp/safari-helper`705 - From source clone: `/path/to/safari-mcp/safari-helper`7064. Make sure the toggle next to it is **ON**.707708The 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.709710If `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.711712### Granting Automation → Safari (important for IDE users)713714macOS 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**.715716If the permission dialog never appears automatically, run this command once from a Terminal that already has Automation permission:717718```bash719osascript -e 'tell application "Safari" to get URL of current tab of window 1'720```721722That 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.723724---725726## Troubleshooting727728| Issue | Fix |729|-------|-----|730| "AppleScript error" | Enable "Allow JavaScript from Apple Events" in Safari → Develop |731| "Not authorized to send Apple events to Safari" | Grant Automation → Safari to your IDE (see above) |732| "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 |733| `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 |734| Screenshots empty | Grant Screen Recording permission to Terminal/VS Code |735| Tab not found | Call `safari_list_tabs` to refresh tab indices |736| Hebrew keyboard issues | All typing uses JS events — immune to keyboard layout |737| HTTPS blocked | `safari_navigate` auto-tries HTTPS first, falls back to HTTP |738| Safari steals focus | Ensure you're on latest version — `newTab` restores your active tab |739740---741742## Works With743744Safari MCP works with any MCP-compatible client:745746| Client | Status |747|--------|--------|748| [Claude Code](https://claude.ai/claude-code) | ✅ Tested daily |749| [Claude Desktop](https://claude.ai/download) | ✅ Tested |750| [Cursor](https://cursor.sh) | ✅ Tested |751| [Windsurf](https://codeium.com/windsurf) | ✅ Compatible |752| [VS Code + Continue](https://continue.dev) | ✅ Compatible |753754---755756## Contributing757758PRs welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for setup instructions.759760The codebase is two files:761- `safari.js` — Safari automation layer (AppleScript + JavaScript)762- `index.js` — MCP server with tool definitions763764---765766## Sponsors767768Safari MCP is free and open source. If it saves you time or CPU cycles, consider supporting its development:769770<a href="https://paypal.me/achiyaC123"><img src="https://img.shields.io/badge/Sponsor-PayPal-blue?logo=paypal" alt="Sponsor via PayPal"></a>771772Your support funds:773- 🧪 Testing across macOS versions and Safari releases774- 🛠️ New tools and features775- 📖 Documentation and examples776777[Become the first sponsor!](https://paypal.me/achiyaC123)778779---780781## Commercial Support782783**Need Safari MCP integrated into your product or agent stack?** [Achiya Automation](https://achiya-automation.com/en/blog/safari-mcp-browser-automation/) offers:784785- **Priority bug fixes** and custom tool development for your use case786- **Integration consulting** — wiring Safari MCP into production agent systems (Claude, Cursor, n8n, custom)787- **Private deployment support** — multi-user Safari MCP, non-standard macOS environments, CI/CD788- **Training workshops** for engineering teams adopting MCP-based automation789790Built by the author of Safari MCP. [Start a conversation →](https://achiya-automation.com/en/contact/)791792---793794## What agents unlock with Safari MCP795796When an AI agent drives Safari MCP, it gets things a headless browser can't:797798- **Real authenticated sessions** — Gmail, GitHub, Ahrefs, Slack, banking dashboards are all already logged in799- **Framework-aware form filling** — `safari_fill_and_submit` calls React/Vue/Angular setters natively, no guessing whether `input` events fired800- **Background operation** — the agent works in parallel while you keep using your Mac801- **One MCP call per workflow** — `safari_run_script` batches navigation + clicks + extraction into a single roundtrip802803The 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.804805---806807## Community808809**6,000+ monthly npm downloads** — developers are building AI agents on macOS with Safari MCP.810811- [GitHub Discussions](https://github.com/achiya-automation/safari-mcp/discussions) — ask questions, share use cases812- [Issues](https://github.com/achiya-automation/safari-mcp/issues) — bug reports and feature requests813- [](https://github.com/achiya-automation/safari-mcp/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) — start contributing814815---816817## Ecosystem818819Other macOS MCP servers that complement Safari MCP:820821| Project | What it does | When to use |822|---------|-------------|-------------|823| [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 |824| [chrome-devtools-mcp](https://github.com/anthropics/chrome-devtools-mcp) | Chrome DevTools Protocol | Lighthouse audits, Chrome-specific performance traces |825826> 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.827828---829830## Like it? Give it a ⭐831832If Safari MCP saves you from Chrome overhead, **a star helps others discover it:**833834[](https://github.com/achiya-automation/safari-mcp)835836[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/)837838[](https://star-history.com/#achiya-automation/safari-mcp&Date)839840---841842## Listed On843844[](https://glama.ai/mcp/servers/achiya-automation/safari-mcp) [](https://registry.modelcontextprotocol.io/) [](https://mcpscoreboard.com/server/05977769-8762-4e89-aff3-a0c5776843bb/) [](https://github.com/achiya-automation/safari-mcp/actions/workflows/ci.yml)845846---847848## License849850MIT — use it however you want.851852---853854Built by **[Achiya Automation](https://achiya-automation.com)** — automation & AI agents for business.855
Full transparency — inspect the skill content before installing.