
Safari MCP
Native Safari browser automation for AI agents on macOS — 80 tools, your real logged-in browser, no Chrome.
Add to your client
Copy the config for your MCP client and paste it into its config file.
npx safari-mcpPaste into ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"safari-mcp": {
"command": "npx",
"args": [
"safari-mcp"
]
}
}
}Step-by-step guides: Add to Claude Desktop · Add to Cursor · Add to Windsurf
Before you start
- macOS (any version with Safari)
- Node.js 18+
- Safari → Settings → Advanced → Show features for web developers enabled
- Safari → Develop → Allow JavaScript from Apple Events enabled
- Automation → Safari permission granted to the MCP client's parent process (e.g. VS Code or Terminal)
- Optional: Safari MCP extension (built via Xcode) for closed Shadow DOM, strict CSP, and framework-heavy editors
About Safari MCP
Safari MCP is a macOS-only Model Context Protocol server that lets AI agents automate the user's real, logged-in Safari browser via 80 tools, with no Chrome, Puppeteer, Playwright, or WebDriver dependencies. It uses a dual-engine approach: a Safari extension (preferred) plus an AppleScript fallback driven by a persistent Swift helper, achieving ~5ms per command and ~60% less CPU than Chrome while keeping Safari in the background without stealing focus. The recommended workflow is snapshot → interact by ref → snapshot to verify.
Tools & capabilities (79)
safari_navigateNavigate to a URL (auto HTTPS, wait for load).
safari_go_backGo back in browser history.
safari_go_forwardGo forward in browser history.
safari_reloadReload the page (optional hard reload).
safari_read_pageGet the page title, URL, and text content.
safari_get_sourceGet the full HTML source of the page.
safari_navigate_and_readNavigate to a URL and read the page in one call.
safari_clickClick an element by CSS selector, visible text, or coordinates.
safari_double_clickDouble-click an element (e.g. to select a word).
safari_right_clickRight-click to open a context menu.
safari_hoverHover over an element.
safari_click_and_waitClick an element and wait for navigation.
safari_fillFill an input (React/Vue/Angular compatible via native setters).
safari_clear_fieldClear an input field.
safari_select_optionSelect an option from a dropdown.
safari_fill_formBatch fill multiple form fields.
safari_fill_and_submitFill a form and submit it in one call.
safari_type_textType real keystrokes via JavaScript (no System Events).
safari_press_keyPress a key with optional modifiers.
safari_screenshotCapture a screenshot as PNG (viewport or full page).
safari_screenshot_elementScreenshot a specific element.
safari_save_pdfExport the page as a PDF.
safari_scrollScroll up or down by a number of pixels.
safari_scroll_toScroll to an exact position.
safari_scroll_to_elementSmooth scroll to a specific element.
safari_list_tabsList all tabs with index, title, and URL.
safari_new_tabOpen a new tab in the background (no focus steal).
safari_close_tabClose a tab.
safari_switch_tabSwitch to a tab by index.
safari_wait_forWait for an element, text, or URL change.
safari_waitWait for a specified number of milliseconds.
safari_evaluateExecute arbitrary JavaScript and return the result.
safari_get_elementGet element details (tag, rect, attributes, visibility).
safari_query_allFind all elements matching a selector.
safari_get_computed_styleGet computed CSS styles for an element.
safari_detect_formsAuto-detect all forms with their field selectors.
safari_accessibility_snapshotGet the full a11y tree: roles, ARIA, focusable elements.
safari_dragDrag between elements or coordinates.
safari_upload_fileUpload a file via JS DataTransfer (no file dialog).
safari_paste_imagePaste an image into an editor (no clipboard touch).
safari_handle_dialogHandle alert/confirm/prompt dialogs.
safari_resizeResize the browser window.
safari_emulateEmulate a device (iPhone, iPad, Pixel, Galaxy).
safari_reset_emulationReset device emulation back to desktop.
safari_get_cookiesGet all cookies.
safari_set_cookieSet a cookie with all options.
safari_delete_cookiesDelete one or all cookies.
safari_local_storageRead localStorage.
safari_set_local_storageWrite to localStorage.
safari_delete_local_storageDelete or clear localStorage.
safari_session_storageRead sessionStorage.
safari_set_session_storageWrite to sessionStorage.
safari_delete_session_storageDelete or clear sessionStorage.
safari_export_storageExport all storage as JSON (backup/restore sessions).
safari_import_storageImport storage state from JSON.
safari_clipboard_readRead clipboard text.
safari_clipboard_writeWrite text to the clipboard.
safari_networkGet quick network requests via the Performance API.
safari_start_network_captureStart detailed network capture (fetch + XHR).
safari_network_detailsGet captured requests with headers and timing.
safari_clear_networkClear captured network requests.
safari_mock_routeMock network responses (intercept fetch/XHR).
safari_clear_mocksRemove all network mocks.
safari_start_consoleStart capturing console messages.
safari_get_consoleGet all captured console messages.
safari_clear_consoleClear captured console messages.
safari_console_filterFilter console messages by level (log/warn/error).
safari_performance_metricsGet navigation timing, Web Vitals, and memory.
safari_throttle_networkSimulate slow-3g/fast-3g/4g/offline network conditions.
safari_extract_tablesExtract tables as structured JSON.
safari_extract_metaExtract all meta: OG, Twitter, JSON-LD, canonical.
safari_extract_imagesExtract images with dimensions and loading info.
safari_extract_linksExtract links with rel, external/nofollow detection.
safari_override_geolocationOverride the browser geolocation.
safari_list_indexed_dbsList IndexedDB databases.
safari_get_indexed_dbRead IndexedDB records.
safari_css_coverageFind unused CSS rules.
safari_analyze_pageRun a full page analysis in one call.
safari_run_scriptRun multiple actions in a single batched call.
What this server can do
Safari MCP provides tools for these capabilities — tap one to see every MCP server that does the same:
When to use it
- Let an AI coding agent drive your real, logged-in Safari (Gmail, GitHub, Ahrefs, Slack, dashboards) without re-authenticating
- Automate modern SPAs with closed Shadow DOM or strict CSP using the Safari extension engine
- Fill and submit React/Vue/Angular forms reliably via native setters
- Scrape structured data — tables, meta tags, images, links — and capture or mock network requests
- Run background browser automation on macOS with minimal CPU/heat while you keep using your Mac
Security notes
Runs locally on macOS with no remote connections (stdio + localhost only) and no telemetry. The optional Safari extension communicates only with localhost:9224. Requires macOS system permissions: Automation → Safari (granted to the parent process running the MCP client, e.g. VS Code/Terminal), "Allow JavaScript from Apple Events" in Safari's Develop menu, Screen Recording (for screenshots), and Accessibility for safari-helper (for native CGEvent click/keyboard tools). The safari_evaluate tool runs arbitrary JavaScript in your real, logged-in Safari, so it has access to authenticated sessions.
Safari MCP FAQ
Does Safari MCP work without installing the Safari extension?
Yes. Roughly 80% of functionality works through the AppleScript engine alone. The optional extension adds closed Shadow DOM access, strict-CSP bypass via the MAIN world, deeper framework state manipulation, and smart loading-state detection.
Is it cross-platform?
No. Safari MCP is macOS only, since it drives Safari via AppleScript/WebKit. It requires Node.js 18+ and enabling 'Allow JavaScript from Apple Events' in Safari's Develop menu.
Why does Automation permission need to be granted to my IDE rather than to safari-mcp?
macOS TCC grants Automation permission to the parent process that spawns the MCP server (e.g. VS Code or Terminal), not to safari-mcp itself. If the prompt doesn't appear, run `osascript -e 'tell application "Safari" to get URL of current tab of window 1'` once from a Terminal that already has Automation permission to register it.
Does it send any data remotely?
No. All communication is local (stdio plus localhost), there's no telemetry or analytics, and the code is fully open source under MIT. The optional extension talks only to localhost:9224.
Alternatives to Safari MCP
Compare all alternatives →All-in-one web access MCP — Web Unlocker, SERP, Scraper API, and a cloud Scraping Browser.
Popular community Playwright + API testing MCP server with codegen, screenshots, and device emulation.
Official Browserbase cloud-browser MCP built on Stagehand — natural-language act/extract/observe.