Safari MCP Server
🦁 Safari MCP
The only MCP server for Safari — native browser automation for AI agents.
80 tools · No Chrome/Puppeteer/Playwright needed · ~5ms per command · 60% less CPU than Chrome
Quick Start · All 80 Tools · Examples · Why Safari MCP? · Architecture · Changelog

TL;DR: Use your real Safari with all your logins, cookies, and sessions. No headless browsers, no Chrome, no Puppeteer. Just native AppleScript + JavaScript on macOS — 60% less CPU/heat on Apple Silicon.
📰 Featured on HackerNoon: I Had to Reverse-Engineer React, Shadow DOM, and CSP to Automate Safari Without Chrome — the three hardest technical problems behind Safari MCP and the code that solved them.
🤔 Why not just use Playwright or Chrome DevTools MCP?
Problem | Safari MCP Solution |
Chrome DevTools MCP heats up your Mac | Native WebKit — ~60% less CPU |
Playwright launches a new browser without your logins | Uses your real Safari with all sessions |
Puppeteer requires Chrome + debug port | Just AppleScript — no extra browser |
Headless browsers can't access your authenticated sessions | Gmail, GitHub, Slack — already logged in |
Browser automation steals window focus | Safari stays in background, never interrupts |
Highlights
80 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)
npx safari-mcpThat's it — no global install needed. Or install permanently:
npm install -g safari-mcpConfigure your MCP client
Add to your client's config file — all clients use the same JSON:
{
"mcpServers": {
"safari": {
"command": "npx",
"args": ["safari-mcp"]
}
}
}Client | Config file |
Claude Code |
|
Claude Desktop |
|
Cursor |
|
Windsurf |
|
VS Code + Continue |
|
brew install achiya-automation/tap/safari-mcpgit clone https://github.com/achiya-automation/safari-mcp.git
cd safari-mcp && npm install⭐ Found Safari MCP useful?
A star takes 2 seconds and helps other macOS developers discover this.
4,000+ developers install Safari MCP every month. Less than 1% star it. If it saves you Chrome heat, give it back a click.
📰 Read the deep-dive on HackerNoon →
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 resultElement targeting — tools accept multiple targeting strategies:
Strategy | Example | Best for |
CSS selector |
| Unique elements |
Visible text |
| Buttons, links |
Coordinates |
| Canvas, custom widgets |
Ref from snapshot |
| Any element from accessibility tree |
Tip: Start with
safari_snapshotto get element refs, then use refs for precise targeting. This is faster and more reliable than CSS selectors.
Tools (80)
Navigation (4)
Tool | Description |
| Navigate to URL (auto HTTPS, wait for load) |
| Go back in history |
| Go forward in history |
| Reload page (optional hard reload) |
Page Reading (3)
Tool | Description |
| Get title, URL, and text content |
| Get full HTML source |
| Navigate + read in one call |
Click & Interaction (5)
Tool | Description |
| Click by CSS selector, visible text, or coordinates |
| Double-click (select word, etc.) |
| Right-click (context menu) |
| Hover over element |
| Click + wait for navigation |
Form Input (7)
Tool | Description |
| Fill input (React/Vue/Angular compatible) |
| Clear input field |
| Select dropdown option |
| Batch fill multiple fields |
| Fill form + submit in one call |
| Type real keystrokes (JS-based, no System Events) |
| Press key with modifiers |
Screenshots & PDF (3)
Tool | Description |
| Screenshot as PNG (viewport or full page) |
| Screenshot a specific element |
| Export page as PDF |
Scroll (3)
Tool | Description |
| Scroll up/down by pixels |
| Scroll to exact position |
| Smooth scroll to element |
Tab Management (4)
Tool | Description |
| List all tabs (index, title, URL) |
| Open new tab (background, no focus steal) |
| Close tab |
| Switch to tab by index |
Wait (2)
Tool | Description |
| Wait for element, text, or URL change |
| Wait for specified milliseconds |
JavaScript (1)
Tool | Description |
| Execute arbitrary JavaScript, return result |
Element Inspection (4)
Tool | Description |
| Element details (tag, rect, attrs, visibility) |
| Find all matching elements |
| Computed CSS styles |
| Auto-detect all forms with field selectors |
Accessibility (1)
Tool | Description |
| Full a11y tree: roles, ARIA, focusable elements |
Drag & Drop (1)
Tool | Description |
| Drag between elements or coordinates |
File Operations (2)
Tool | Description |
| Upload file via JS DataTransfer (no file dialog!) |
| Paste image into editor (no clipboard touch!) |
Dialog & Window (2)
Tool | Description |
| Handle alert/confirm/prompt |
| Resize browser window |
Device Emulation (2)
Tool | Description |
| Emulate device (iPhone, iPad, Pixel, Galaxy) |
| Reset to desktop |
Cookies & Storage (10)
Tool | Description |
| Get all cookies |
| Set cookie with all options |
| Delete one or all cookies |
| Read localStorage |
| Write localStorage |
| Delete/clear localStorage |
| Read sessionStorage |
| Write sessionStorage |
| Delete/clear sessionStorage |
| Export all storage as JSON (backup/restore sessions) |
| Import storage state from JSON |
Clipboard (2)
Tool | Description |
| Read clipboard text |
| Write text to clipboard |
Network (6)
Tool | Description |
| Quick network requests via Performance API |
| Start detailed capture (fetch + XHR) |
| Get captured requests with headers/timing |
| Clear captured requests |
| Mock network responses (intercept fetch/XHR) |
| Remove all network mocks |
Console (4)
Tool | Description |
| Start capturing console messages |
| Get all captured messages |
| Clear captured messages |
| Filter by level (log/warn/error) |
Performance (2)
Tool | Description |
| Navigation timing, Web Vitals, memory |
| Simulate slow-3g/fast-3g/4g/offline |
Data Extraction (4)
Tool | Description |
| Tables as structured JSON |
| All meta: OG, Twitter, JSON-LD, canonical |
| Images with dimensions and loading info |
| Links with rel, external/nofollow detection |
Advanced (5)
Tool | Description |
| Override browser geolocation |
| List IndexedDB databases |
| Read IndexedDB records |
| Find unused CSS rules |
| Full page analysis in one call |
Automation (1)
Tool | Description |
| Run multiple actions in a single call (batch) |
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 |
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 | 80 | ~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.
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) | |||
Tools | 80 | ~10 | 23 | ~15 |
Install |
| Manual | Binary |
|
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 DOMKey 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 to build from source.
Prerequisites: Xcode (install from App Store — free)
# 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:
Safari → Settings → Advanced → enable Show features for web developers
Safari → Develop → Allow Unsigned Extensions (required each Safari restart)
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 |
Automation → Safari | System Settings → Privacy & Security → Automation | Required for all AppleScript-backed tools |
Screen Recording | System Settings → Privacy & Security → Screen Recording | Required for |
Accessibility | System Settings → Privacy & Security → Accessibility | Required for |
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:
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 | Updating changes the binary's cdhash — macOS silently revokes Automation permission. Re-run the |
Screenshots empty | Grant Screen Recording permission to Terminal/VS Code |
Tab not found | Call |
Hebrew keyboard issues | All typing uses JS events — immune to keyboard layout |
HTTPS blocked |
|
Safari steals focus | Ensure you're on latest version — |
Works With
Safari MCP works with any MCP-compatible client:
Client | Status |
✅ Tested daily | |
✅ Tested | |
✅ Tested | |
✅ Compatible | |
✅ Compatible |
Contributing
PRs welcome! See 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:
Your support funds:
🧪 Testing across macOS versions and Safari releases
🛠️ New tools and features
📖 Documentation and examples
Community
2,000+ monthly npm downloads — developers are using Safari MCP to build AI agents on macOS.
GitHub Discussions — ask questions, share use cases
Issues — bug reports and feature requests
— start contributing
Ecosystem
Other macOS MCP servers that complement Safari MCP:
Project | What it does | When to use |
OS-level macOS automation (accessibility, screen control) | System-wide interactions beyond Safari | |
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:
Share on Twitter/X · Share on LinkedIn · Write about it
Listed On
License
MIT — use it however you want.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/achiya-automation/safari-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server