Labsco
achiya-automation logo

Safari MCP

β˜… 136

from achiya-automation

Native Safari browser automation for AI agents β€” 80 tools via AppleScript, zero Chrome overhead, keeps logins. macOS only.

πŸ”₯πŸ”₯πŸ”₯πŸ”₯βœ“ VerifiedFreeAdvanced setup
<div align="center"> <img src="social-preview.png" alt="Safari MCP Server β€” 97 native browser automation tools for AI agents on macOS" width="100%"> <br/>

🦁 Safari MCP

The browser for your coding agent.

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

npm version npm downloads License: MIT macOS

Glama AAA MCP Registry Smithery MCP Score

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

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

Safari MCP Demo

</div>

❌ 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 Β· HackerNoon: Reverse-Engineering React, Shadow DOM, and CSP

🍎 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

Tools (97)

<details> <summary><b>Click to expand the full tool list β€” organized by category</b></summary>

Navigation (4)

ToolDescription
safari_navigateNavigate to URL (auto HTTPS, wait for load)
safari_go_backGo back in history
safari_go_forwardGo forward in history
safari_reloadReload page (optional hard reload)

Page Reading (3)

ToolDescription
safari_read_pageGet title, URL, and text content
safari_get_sourceGet full HTML source
safari_navigate_and_readNavigate + read in one call

Click & Interaction (6)

ToolDescription
safari_clickClick by CSS selector, visible text, or coordinates
safari_double_clickDouble-click (select word, etc.)
safari_right_clickRight-click (context menu)
safari_hoverHover over element
safari_click_and_waitClick + wait for navigation
safari_click_and_readClick then return the updated page β€” saves a round-trip (React Router + full loads)

Form Input (11)

ToolDescription
safari_fillFill input (React/Vue/Angular compatible)
safari_clear_fieldClear input field
safari_select_optionSelect dropdown option
safari_fill_formBatch fill multiple fields
safari_fill_and_submitFill form + submit in one call
safari_type_textType real keystrokes (JS-based, no System Events)
safari_press_keyPress key with modifiers
safari_react_select_setSet a react-select v5 value via React fiber β€” bypasses the menu UI
safari_react_select_list_optionsList a react-select v5 dropdown's options without opening it
safari_replace_editorReplace all content in a code editor (Monaco, CodeMirror, Ace, ProseMirror)
safari_verify_stateVerify an editor's framework-level state matches expected β€” catch stale DOM before Submit

Screenshots & PDF (3)

ToolDescription
safari_screenshotScreenshot as PNG (viewport or full page)
safari_screenshot_elementScreenshot a specific element
safari_save_pdfExport page as PDF

Scroll (3)

ToolDescription
safari_scrollScroll up/down by pixels
safari_scroll_toScroll to exact position
safari_scroll_to_elementSmooth scroll to element

Tab Management (5)

ToolDescription
safari_list_tabsList all tabs (index, title, URL)
safari_new_tabOpen new tab (background, no focus steal)
safari_close_tabClose tab
safari_switch_tabSwitch to tab by index
safari_wait_for_new_tabWait for a new tab (e.g. OAuth popup) and auto-switch to it

Wait (2)

ToolDescription
safari_wait_forWait for element, text, or URL change
safari_waitWait for specified milliseconds

JavaScript (1)

ToolDescription
safari_evaluateExecute arbitrary JavaScript, return result
safari_eval_fileExecute JavaScript read from a file path (avoids huge inline scripts)

Element Inspection (4)

ToolDescription
safari_get_elementElement details (tag, rect, attrs, visibility)
safari_query_allFind all matching elements
safari_get_computed_styleComputed CSS styles
safari_detect_formsAuto-detect all forms with field selectors

Accessibility (2)

ToolDescription
safari_accessibility_snapshotFull a11y tree: roles, ARIA, focusable elements
safari_snapshotAccessibility tree with ref IDs for every interactive element β€” preferred way to see page state

Drag & Drop (1)

ToolDescription
safari_dragDrag between elements or coordinates

File Operations (2)

ToolDescription
safari_upload_fileUpload file via JS DataTransfer (no file dialog!)
safari_paste_imagePaste image into editor (no clipboard touch!)

Dialog & Window (2)

ToolDescription
safari_handle_dialogHandle alert/confirm/prompt
safari_resizeResize browser window

Device Emulation (2)

ToolDescription
safari_emulateEmulate device (iPhone, iPad, Pixel, Galaxy)
safari_reset_emulationReset to desktop

Cookies & Storage (11)

ToolDescription
safari_get_cookiesGet all cookies
safari_set_cookieSet cookie with all options
safari_delete_cookiesDelete one or all cookies
safari_local_storageRead localStorage
safari_set_local_storageWrite localStorage
safari_delete_local_storageDelete/clear localStorage
safari_session_storageRead sessionStorage
safari_set_session_storageWrite sessionStorage
safari_delete_session_storageDelete/clear sessionStorage
safari_export_storageExport all storage as JSON (backup/restore sessions)
safari_import_storageImport storage state from JSON

Clipboard (2)

ToolDescription
safari_clipboard_readRead clipboard text
safari_clipboard_writeWrite text to clipboard

Network (6)

ToolDescription
safari_networkQuick network requests via Performance API
safari_start_network_captureStart detailed capture (fetch + XHR)
safari_network_detailsGet captured requests with headers/timing
safari_clear_networkClear captured requests
safari_mock_routeMock network responses (intercept fetch/XHR)
safari_clear_mocksRemove all network mocks

Console (4)

ToolDescription
safari_start_consoleStart capturing console messages
safari_get_consoleGet all captured messages
safari_clear_consoleClear captured messages
safari_console_filterFilter by level (log/warn/error)

Performance (2)

ToolDescription
safari_performance_metricsNavigation timing, Web Vitals, memory
safari_throttle_networkSimulate slow-3g/fast-3g/4g/offline

Data Extraction (4)

ToolDescription
safari_extract_tablesTables as structured JSON
safari_extract_metaAll meta: OG, Twitter, JSON-LD, canonical
safari_extract_imagesImages with dimensions and loading info
safari_extract_linksLinks with rel, external/nofollow detection

Advanced (7)

ToolDescription
safari_override_geolocationOverride browser geolocation
safari_list_indexed_dbsList IndexedDB databases
safari_get_indexed_dbRead IndexedDB records
safari_css_coverageFind unused CSS rules
safari_analyze_pageFull page analysis in one call
safari_doctorDiagnose the macOS permission + daemon chain (Apple Events, Accessibility, Screen Recording, codesign) with per-failure fixes
safari_reload_extensionHot-reload the Safari MCP Bridge extension without a manual toggle

Automation (1)

ToolDescription
safari_run_scriptRun multiple actions in a single call (batch)

Native Input β€” CGEvent (4)

ToolDescription
safari_native_clickOS-level mouse click (CGEvent, isTrusted: true) β€” bypasses WAF/bot detection when safari_click is blocked (405/403)
safari_native_hoverOS-level cursor hover β€” triggers real :hover/mouseenter for tooltips and obfuscated UIs
safari_native_typeInsert text via the real paste pipeline β€” ProseMirror/Slate/Draft.js process it natively so Submit sends real data
safari_native_keyboardOS-level keypress + modifiers to Safari, no focus steal β€” reaches React trust-gated handlers (Discord/Slack send)

iOS & WebKit Validation (4)

ToolDescription
safari_inspect_viewportValidate the <meta name=viewport> tag for iOS Safari (device-width, zoom/WCAG, viewport-fit)
safari_safe_area_insetsRead live safe-area-inset values + viewport-fit / env() usage (notch / Dynamic Island)
safari_check_pwaAudit iOS "Add to Home Screen" / PWA readiness (apple-touch-icon, manifest, theme-color, splash)
safari_webkit_compatCheck page CSS against this Safari via CSS.supports() β€” unsupported props, missing -webkit- prefixes, known quirks
</details>

Security

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

AspectDetail
NetworkNo remote connections β€” all communication is local (stdio + localhost)
PermissionsmacOS system permissions required (Screen Recording for screenshots)
DataNo telemetry, no analytics, no data sent anywhere
ExtensionCommunicates only with localhost:9224, validated by Safari
CodeFully open source (MIT) β€” audit every line

Safari MCP vs Alternatives

FeatureSafari MCPChrome DevTools MCPPlaywright MCP
CPU/Heat🟒 MinimalπŸ”΄ High🟑 Medium
Your loginsβœ… Yesβœ… Yes❌ No
macOS nativeβœ… WebKit❌ Chromium❌ Chromium/WebKit
Browser dependenciesNoneChrome + debug portPlaywright runtime
Tools97~30~25
File uploadJS (no dialog)CDPPlaywright API
Image pasteJS (no clipboard)CDPPlaywright 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
Tools97~17
Storage (cookies, localStorage, IndexedDB)βœ… 10 tools❌
Network mocking + throttlingβœ… Yes❌ Read-only network inspection
Device emulation (iPhone, iPad)βœ… Yes⚠️ Viewport + media type only
Setupnpx safari-mcpEnable "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-serverEpistates/MCPSafariHayoDev/safari-devtools-mcp
Tools97~1023~15
Installnpx safari-mcpManualBinarynpx
EngineDual (Extension + AppleScript)WebDriverExtension onlyDevTools Protocol
Keeps your real Safari loginsβœ… Yes⚠️ Limitedβœ… Yes❌ Debug session
Background (no focus steal)βœ… Yes❌ No⚠️ Sometimesβœ… Yes
Storage tools (cookies, localStorage, IndexedDB)10002
Data extraction (tables, meta, images, links)4000
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 capture4 tools011
Performance metrics + Web Vitalsβœ… Yes❌ No❌ No⚠️ Partial
Active maintenanceβœ… Multiple releases/week🟑 Sporadic🟑 Slow🟑 Slow
LicenseMITMITNone specifiedMIT
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:

Copy & paste β€” that's it
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

CapabilityWith ExtensionAppleScript 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)

Copy & paste β€” that's it
# 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:

PermissionWhereWhy
JavaScript from Apple EventsSafari β†’ Develop menuRequired for do JavaScript
Automation β†’ SafariSystem Settings β†’ Privacy & Security β†’ AutomationRequired for all AppleScript-backed tools
Screen RecordingSystem Settings β†’ Privacy & Security β†’ Screen RecordingRequired for safari_screenshot
Accessibility (safari-helper)System Settings β†’ Privacy & Security β†’ AccessibilityRequired 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:

Copy & paste β€” that's it
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.


Works With

Safari MCP works with any MCP-compatible client:

ClientStatus
Claude Codeβœ… Tested daily
Claude Desktopβœ… Tested
Cursorβœ… Tested
Windsurfβœ… Compatible
VS Code + Continueβœ… 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:

<a href="https://paypal.me/achiyaC123"><img src="https://img.shields.io/badge/Sponsor-PayPal-blue?logo=paypal" alt="Sponsor via PayPal"></a>

Your support funds:

  • πŸ§ͺ Testing across macOS versions and Safari releases
  • πŸ› οΈ New tools and features
  • πŸ“– Documentation and examples

Become the first sponsor!


Commercial Support

Need Safari MCP integrated into your product or agent stack? Achiya 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 β†’


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 β€” ask questions, share use cases
  • Issues β€” bug reports and feature requests
  • Good First Issues β€” start contributing

Ecosystem

Other macOS MCP servers that complement Safari MCP:

ProjectWhat it doesWhen to use
mcp-server-macos-useOS-level macOS automation (accessibility, screen control)System-wide interactions beyond Safari
chrome-devtools-mcpChrome DevTools ProtocolLighthouse 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

Share on Twitter/X Β· Share on LinkedIn Β· Write about it

Star History Chart


Listed On

Glama MCP Registry MCP Scoreboard CI


License

MIT β€” use it however you want.