Safari MCP Server
Provides a comprehensive suite of 80 tools for native Safari browser automation on macOS, enabling navigation, element interaction, tab management, and session-aware browsing while preserving existing user logins and cookies.
🦁 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.
🤔 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 installUsage 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.
Safari MCP Servers Comparison
Feature | safari-mcp | MCPSafari | safari-mcp-server |
Tools | 80 | 23 | ~10 |
License | MIT | None | MIT |
Install | npm / Homebrew | Binary | npm |
Storage (cookies, localStorage) | 10 tools | None | None |
Data extraction (tables, links) | 5 tools | None | None |
Network mocking | Yes | No | No |
Device emulation | Yes | No | No |
File upload (no dialog) | Yes | No | No |
PDF export | Yes | No | No |
Console capture | 4 tools | 1 | No |
Performance metrics | Yes | No | No |
Fallback engine | Dual (Extension + AppleScript) | Extension only | WebDriver |
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
xcodebuild -project "xcode/Safari MCP/Safari MCP.xcodeproj" \
-scheme "Safari MCP (macOS)" -configuration Release build
# 2. Find and open the built app
open ~/Library/Developer/Xcode/DerivedData/Safari_MCP-*/Build/Products/Release/Safari\ MCP.appThen 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 |
Screen Recording | System Settings → Privacy | Required for |
Accessibility | System Settings → Privacy | Required for |
Troubleshooting
Issue | Fix |
"AppleScript error" | Enable "Allow JavaScript from Apple Events" in Safari → Develop |
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+ weekly 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
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