safari-mcp
Reads and controls the user's real Safari browser on macOS via AppleScript: lists windows and tabs (with private-window flags), finds/reuses/opens/closes/activates tabs, navigates and reloads, reads page content in visible, readability or full-DOM modes (plus markdown, HTML, selection, links, images, in-page search and summary extracts), produces Playwright-style page snapshots, queries and clicks elements, types text, submits forms, scrolls, waits for elements/navigation/text, runs arbitrary JavaScript, and captures screenshots.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@safari-mcp Summarize the article I have open in Safari."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
An example conversation, using the tools listed below:
You: Summarize the article I have open in Safari.
Agent: safari_get_active_tab -> https://example.com/post "Example post"
safari_get_page_markdown -> (page as markdown)
Agent: The post argues that ...safari-mcp is a Model Context Protocol server that runs on your Mac and talks to the Safari you already use. An agent such as Claude Code, Codex or Claude Desktop can list your tabs, read pages, click, type, wait for changes and run JavaScript.
It is for people who want an agent to work inside their real, logged-in Safari instead of a fresh automated browser. It drives Safari through macOS scripting (osascript), so there is no browser framework to install and nothing leaves your machine.
Features
Works with the tabs you have open. Find a tab by URL or title, list every window and tab (with a private-window flag), and reuse a tab instead of opening a duplicate.
Page reading in three modes. Read
visible,readability(article text) orfull_domcontent, or get markdown, raw HTML, links, images, the current selection or a summary-ready extract.Playwright-style snapshots.
safari_snapshot_pagereturns a structured page map with viewport info and the elements an agent can act on.DOM interaction. Query elements, click (with basic interactability checks), type, submit forms, scroll and list forms and fields.
Reliable waits. Wait for an element, for navigation to finish, or for text to appear or disappear.
Screenshots. Uses the Safari WebDriver when it is enabled and falls back to a Chrome-based render of the page snapshot.
Local only. Plain stdio server. It makes no network requests of its own beyond the localhost connection to
safaridriverused for screenshots.
Related MCP server: Safari MCP Server
Requirements
macOS with Safari at
/Applications/Safari.appNode.js 20 or later
In Safari: the Develop menu and
Allow JavaScript from Apple Eventsturned onOptional, for screenshots:
Allow remote automationin Safari, or Google Chrome, Chrome Canary or Chromium in/Applications
Turn on the Safari settings from Terminal:
defaults write com.apple.Safari IncludeDevelopMenu -bool true
defaults write com.apple.Safari AllowJavaScriptFromAppleEvents -bool true
killall Safari || true
open -a /Applications/Safari.appThen in Safari, open Develop > Developer Settings… and turn on Allow remote automation if you want the WebDriver screenshot backend.
Install
safari-mcp is not published to npm (the safari-mcp name on npm belongs to a different project). Install from source:
git clone https://github.com/tszaks/safari-mcp.git
cd safari-mcp
npm install
npm run buildThe entry point is dist/index.js. Use its absolute path in the client configs below (/Users/you/safari-mcp/dist/index.js is an example). It needs no environment variables.
Client configuration
Claude Code
claude mcp add safari -- node /Users/you/safari-mcp/dist/index.jsCodex
Add this to ~/.codex/config.toml:
[mcp_servers.safari]
command = "node"
args = ["/Users/you/safari-mcp/dist/index.js"]Claude Desktop
Add this to claude_desktop_config.json (Settings > Developer > Edit Config):
{
"mcpServers": {
"safari": {
"command": "node",
"args": ["/Users/you/safari-mcp/dist/index.js"]
}
}
}Tools
The server registers 33 tools (the list comes from src/tooling.ts). Most take optional window_index and tab_index (1-based) to pick a tab. Without them, the active tab is used.
Tool | What it does |
| URL and title of the active tab |
| Find open tabs by URL or title substring |
| List tabs across all windows, with a private flag per window |
| List windows and their tabs |
| Navigate the active tab to a URL (no new tab or window) |
| Open a new tab in the front window |
| Close a tab |
| Close several tabs in a window |
| Focus a tab |
| Bring a window to the front |
| Reload a tab |
| Go back in a tab |
| Go forward in a tab |
| Read page content ( |
| Page content as markdown |
| Structured page snapshot with actionable elements |
| Full page HTML |
| The selected text |
| Links on the page |
| Images on the page |
| Find text occurrences in the page |
| Summary-ready page content |
| Run JavaScript in the page |
| Query DOM elements |
| Click an element, with interactability checks |
| Type text into an element |
| Submit a form |
| Scroll the page |
| Wait for an element to appear |
| Wait for navigation to finish loading |
| Wait for text to appear or disappear |
| List forms and their fields |
| Screenshot of the visible area, saved as a PNG in a temp folder |
Using with agents
The tool descriptions steer agents to reuse what you already have open: call safari_get_active_tab first, use safari_find_tab before safari_open_url, and prefer safari_open_url over safari_new_tab. safari_new_tab never opens a new window or a private window. Prefer non-private windows when you want an agent to use a logged-in session. See docs/agents.md.
FAQ
What can an agent see and do? Anything in Safari that you can. That includes pages where you are logged in, the text and HTML of those pages, form contents, and any JavaScript it runs in them. Treat access to this server like access to your browser. See Permissions and privacy.
Does it send data anywhere? The server sends nothing over the network itself. The agent that calls it does see the page data the tools return, and your AI client sends that to its model provider. For screenshots, the server starts /usr/bin/safaridriver on a random localhost port and talks to it over 127.0.0.1 only.
Why does Safari sometimes come to the front? Some operations (activating tabs or windows, opening Safari) bring Safari forward.
Permissions and privacy
Apple Events (Automation). The first time an agent uses a tool, macOS asks whether your terminal or MCP client may control Safari. Allow it under System Settings > Privacy & Security > Automation.
Safari settings.
Allow JavaScript from Apple Eventsis required: that is how the server reads pages and runs scripts in them.Data it can read. Tab URLs and titles for all windows (private windows included, flagged
private), page text and HTML, form fields and their values, links, images, and the result of any JavaScript the agent runs.Data it can change. It can navigate, close tabs, click, type, submit forms and run arbitrary JavaScript in any open page. There is no read-only mode.
Files it writes. Screenshots are written as PNG (and a temporary HTML file for the Chrome fallback) into a new folder under your system temp directory named
safari-mcp-*.Network. None from the server itself, apart from the localhost WebDriver connection for screenshots.
Development
npm install
npm run typecheck
npm run build
npm testnpm test builds and then runs the tests in test/. Some of them drive your real Safari (they read the active tab, list tabs and open a URL), so run them on a Mac where that is fine.
Contributing
Read CONTRIBUTING.md. Security issues go through SECURITY.md. Everyone taking part follows the Code of Conduct. Changes are listed in CHANGELOG.md. Agents working on the code should read AGENTS.md.
License
Available Tools
33 toolssafari_activate_tabC
Focus a specific Safari tab.
Inputs: tab_index, window_index.
safari_activate_windowC
Bring a Safari window to the front.
Inputs: window_index (required).
safari_click_elementC
Click an element in the current Safari page.
Inputs: selector (required), tab_index, window_index.
safari_close_tabC
Close a Safari tab.
Inputs: tab_index, window_index.
safari_close_tabsC
Close multiple Safari tabs in a window.
Inputs: tab_indices, window_index.
safari_extract_imagesC
Extract images from the current Safari page.
Inputs: limit, tab_index, window_index.
safari_extract_linksC
Extract links from the current Safari page.
Inputs: limit, tab_index, window_index.
safari_find_in_pageC
Find text occurrences in the current Safari page.
Inputs: query (required), limit, tab_index, window_index.
safari_find_tabA
Search all open Safari tabs by URL or title substring. Returns matching tabs with window_index and tab_index so you can activate them. Use this before safari_open_url to avoid opening a duplicate tab or losing the user's existing session (e.g. their logged-in GitHub tab).
Inputs: query (required).
safari_get_active_tabA
Get metadata (URL, title) for the currently active Safari tab. Call this FIRST before navigating anywhere — the user may already have the page open.
Inputs: no named parameters.
safari_get_page_contentC
Read page content from Safari.
Inputs: mode, tab_index, window_index.
safari_get_page_htmlC
Return full page HTML from Safari.
Inputs: tab_index, window_index.
safari_get_page_markdownC
Return page content as summary-friendly markdown.
Inputs: mode, tab_index, window_index.
safari_get_selectionC
Get the selected text from Safari.
Inputs: tab_index, window_index.
safari_go_backC
Navigate back in a Safari tab.
Inputs: tab_index, window_index.
safari_go_forwardC
Navigate forward in a Safari tab.
Inputs: tab_index, window_index.
safari_list_formsC
List forms and fields from the current Safari page.
Inputs: tab_index, window_index.
safari_list_tabsA
List all Safari tabs across all windows (includes private flag per window). Use this to discover what is already open before navigating.
Inputs: window_index.
safari_list_windowsA
List Safari windows and their tabs. Each window includes a "private" flag — prefer non-private windows to access logged-in sessions.
Inputs: no named parameters.
safari_new_tabA
Open a NEW Safari tab in the existing front window (never opens a new window, never opens private/incognito). Only use this when you specifically need a separate tab. For simple navigation, use safari_open_url instead.
Inputs: url.
safari_open_urlA
Navigate the existing active Safari tab to a URL. Does NOT open a new window or tab — it reuses the current tab. Prefer this over safari_new_tab whenever you just need to visit a URL.
Inputs: url (required), window_index.
safari_query_elementsC
Query DOM elements in the current Safari page.
Inputs: selector (required), limit, tab_index, window_index.
safari_reload_tabC
Reload a Safari tab.
Inputs: tab_index, window_index.
safari_run_javascriptC
Run JavaScript in the current Safari page.
Inputs: script (required), tab_index, window_index.
safari_screenshot_visible_areaB
Capture a screenshot of the visible Safari area.
Inputs: no named parameters.
safari_scroll_pageC
Scroll the current Safari page.
Inputs: top, left, percent, behavior, +2 more.
safari_snapshot_pageC
Return a Playwright-style structured snapshot of the current Safari page.
Inputs: tab_index, window_index.
safari_submit_formC
Submit a form in the current Safari page.
Inputs: selector (required), tab_index, window_index.
safari_summarize_pageC
Return summary-ready content for the current Safari page.
Inputs: tab_index, window_index.
safari_type_into_elementC
Type text into an element in the current Safari page.
Inputs: text (required), selector (required), clear, submit, +2 more.
safari_wait_for_elementC
Wait for an element to appear in the current Safari page.
Inputs: selector (required), tab_index, timeout_ms, interval_ms, +1 more.
safari_wait_for_textC
Wait for text to appear or disappear in the current Safari page.
Inputs: text, textGone, tab_index, timeout_ms, +2 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 33 tools
Most tools are clearly scoped (navigation, tab management, waiting, DOM interaction), and descriptions explicitly steer between safari_open_url vs safari_new_tab and find_tab vs list_tabs. However there is a cluster of near-duplicate read operations — get_page_content, get_page_markdown, get_page_html, snapshot_page, summarize_page — whose boundaries an agent must guess at, and list_tabs/list_windows/find_tab overlap in purpose.
Every tool uses the same safari_ prefix followed by a snake_case verb_noun pattern (get_active_tab, close_tab, wait_for_element, run_javascript). No camelCase or bare-noun outliers, and singular/plural pairs (close_tab/close_tabs) are used meaningfully.
33 tools is well past the point where the surface stays legible, and several of the extra tools are redundant rather than additive (five different ways to read page content, three different tab-listing tools). Navigation, waiting, extraction, and interaction could be covered comfortably with roughly 20 tools.
Core browser automation is covered: navigation, tab/window lifecycle, waiting, content extraction, clicking, typing, form submission, scrolling, JS execution, and screenshots. But there are real gaps — no hover, no select/dropdown option, no key-press or keyboard shortcuts, no full-page or element-level screenshot, and no handling of alerts/dialogs or iframes — which will dead-end common flows.
Maintenance
Related MCP Connectors
Control a real browser from AI agents: navigate, click, type, screenshot, read the page.
Let AI agents use your real, signed-in Chrome: tabs, clicks, forms, screenshots and video.
Let your AI agent operate any website through a real, logged-in browser session.
Give AI agents a real cloud Chrome: open sessions, navigate, read pages, click, type and screenshot.
Related MCP Servers
- AlicenseBqualityDmaintenanceProvides AI assistants with Safari browser automation and developer tools access, enabling LLMs to control Safari, access console logs, monitor network activity, and perform browser automation tasks.139 npm33MIT
- AlicenseBqualityAmaintenanceNative Safari browser automation for AI agents. 80 tools via AppleScript — zero overhead, keeps logins, runs silently in background. Drop-in alternative to Chrome DevTools MCP with 40-60% less CPU/heat on Apple Silicon.983,097 npm248MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to drive a real Safari WebKit browser on macOS: navigate pages, click and fill forms, read content as markdown, and extract page records as structured JSON. Named sessions persist logins between commands, and CAPTCHA or bot-check pages are detected and reported.MIT
- FlicenseNot gradedqualityBmaintenanceLets AI agents drive your real, already-logged-in browsers on macOS in the background without stealing focus, organizing work into tab groups, reading pages as compact accessibility snapshots, and saving repeatable scenarios. Supports Chrome, Edge, Brave, Yandex Browser, and Safari, with per-agent isolation and automatic tab cleanup.-