safari-mcp-server
This server lets you automate a real, signed-in Safari session on macOS over MCP, CLI, or Python using DOM-level tab and page control.
List all open tabs across every Safari window with index, URL, title, and current-tab status
Open URLs in the current tab or a new tab, optionally waiting for the page to load
Close a specified tab/window or the frontmost window's current tab
Read a page's URL, title, visible text, and optionally full HTML
Execute arbitrary JavaScript in the page context (requires Safari's "Allow JavaScript from Apple Events")
Click the first element matching a CSS selector; returns found=False if nothing matches
Fill input/textarea values via CSS selector, dispatching real input/change events for JS frameworks
Check whether a CSS selector matches any element
Wait/poll for a selector to appear up to a configurable timeout
Provides tools for driving Safari.app on macOS, enabling navigation, page reading, clicking, and form filling in the user's real Safari browser with existing sessions and cookies.
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-server Open Hacker News in a new tab and read the top headlines"
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.
safari-mcp
Control your real Safari.app session on macOS through an MCP server, CLI, or Python library. The project uses Apple's JavaScript for Automation (JXA) to navigate tabs, read pages, run JavaScript, click CSS-selected elements, and fill forms.
This is your existing signed-in browser, not an isolated automation profile. Actions can affect real accounts and pages. Connect only trusted agents and review consequential actions before execution.
Install and permissions
Requires macOS, Safari, and Python 3.10+. pip installs the MCP dependency.
git clone https://github.com/zhuhroscar-tech/safari-mcp.git
cd safari-mcp
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -e .Enable both permissions:
Allow the launching terminal/app to control Safari under System Settings → Privacy & Security → Automation when prompted.
In Safari Settings → Advanced, enable Show features for web developers, then select Develop → Allow JavaScript from Apple Events. This is required for page JavaScript operations; tab listing, opening, and closing do not require it.
Related MCP server: Safari MCP Server
Connect an MCP host
For hosts using mcpServers configuration:
{
"mcpServers": {
"safari": {
"command": "/absolute/path/to/safari-mcp/.venv/bin/safari-mcp-server"
}
}
}Replace the path with your installation's executable. The server uses stdio and exposes safari_tabs, safari_open, safari_close, safari_read, safari_js, safari_click, safari_fill, safari_element_exists, and safari_wait_for.
CLI and Python
safari-mcp tabs
safari-mcp open "https://example.com" --new-tab
safari-mcp read --json
safari-mcp read --window 1 --tab 1Targeted commands default to the frontmost window's current tab. Window and tab indices are one-based; use --help for supported targeting flags.
from safari_mcp.core import list_tabs, read_page
print(list_tabs())
page = read_page()
print(page.title, page.text[:100])Boundaries
This is DOM automation, not screenshot or coordinate-based interaction. There is no sandbox or incognito isolation, and no Linux/Windows support. The wrapper has no telemetry or separate network client, but browser navigation and page actions can send network requests and change account state. Page content passed to an agent is subject to that host's data handling.
Preview and development
python -m pip install -e ".[dev]"
python -m pytest -v
# Optional: real Safari; requires permissions and an open browser
python tests/e2e_mcp_roundtrip.pyCI tests mocked Safari interaction and packaging; it does not establish live Safari behavior. API implementation · Release history · MIT license
Available Tools
9 toolssafari_clickA
Click the first element matching a CSS selector in a Safari tab. Returns found=False (not an error) if nothing matched the selector.
Inputs: selector (required), tab, window.
safari_closeA
Close a Safari tab. Omit both arguments to close the frontmost window's current tab.
Inputs: tab, window.
safari_element_existsC
Check whether a CSS selector matches any element in a Safari tab.
Inputs: selector (required), tab, window.
safari_fillA
Set an /'s value via a CSS selector, dispatching real 'input'/'change' events so JS-framework-backed forms (React, Vue, ...) observe the change. Returns found=False (not an error) if nothing matched the selector.
Inputs: value (required), selector (required), tab, window.
safari_jsB
Evaluate arbitrary JavaScript in a Safari tab's page context and return the string-coerced result. Requires Safari's Develop menu > 'Allow JavaScript from Apple Events' to be enabled.
Inputs: code (required), tab, window.
safari_openA
Navigate Safari to a URL. Reuses the real, already-logged-in Safari session (cookies, extensions, everything) rather than a separate automation profile. With new_tab=True opens a new tab; otherwise navigates the frontmost window's current tab in place. Waits for the page to finish loading by default so the returned title is accurate.
Inputs: url (required), new_tab, wait_for_load.
safari_readA
Read a Safari tab's URL, title, and visible text (document.body's innerText). Set include_html=True to also get the full outerHTML. Omit window/tab to read the frontmost window's current tab.
Inputs: tab, window, include_html.
safari_tabsA
List every open tab across every Safari window. Each entry has window_index, tab_index, url, title, and is_current (whether it's that window's frontmost tab).
Inputs: no named parameters.
safari_wait_forA
Poll a Safari tab until a CSS selector matches an element, or time out. Useful after a click/navigation that loads content asynchronously. Returns found=False (not an error) on timeout.
Inputs: selector (required), tab, window, timeout_seconds.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Each tool targets a distinct action: tab-level operations (open, close, tabs) vs. page-level interactions (read, click, fill, js) vs. condition checks (element_exists, wait_for). The only conceivable overlap is between element_exists and wait_for, but one is a one-shot check and the other is a polling operation, so the descriptions make them unambiguous.
All tools share the consistent 'safari_' prefix and lowercase snake_case style, and most use a verb-like action word (close, read, click, fill, open). Minor deviations exist: 'safari_tabs' is a noun rather than a verb phrase like 'list_tabs', and 'safari_element_exists' is a noun+verb predicate, but the overall pattern remains predictable.
Nine tools is a well-scoped size for a Safari automation server, covering navigation, tab management, page reading, and DOM interaction without unnecessary bloat. Each tool earns its place for a focused browser-automation purpose.
The core workflows are covered: open URLs, read page content, interact via click/fill/JS, wait for elements, and manage tabs. Minor gaps exist, such as no explicit back/forward navigation, no screenshot capability, and no direct 'activate tab' tool, but these are workaroundable and the essential lifecycle of browsing automation is present.
Maintenance
Related MCP Connectors
Read, crawl and act on websites, signed in as the user, and turn any site into an API.
Programmatic headless browser sessions: create, interact, browse, and extract - rendered in a real
AI-powered browser automation — navigate, click, fill forms, and extract data from any website.
Automate cloud Chrome—navigate, click, type, screenshot, run code, record screen video
Related MCP Servers
- -licenseAqualityNot gradedmaintenanceA server that provides AI assistants programmatic control of Safari browser on macOS for web automation, testing, and debugging.161-
- 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.981,008 npm244MIT
- AlicenseAqualityCmaintenanceEnables visual web access and browser automation through Safari, with tools for navigation, screenshots, element interaction, and tab management.1719 npmBSD 3-Clause
- AlicenseAqualityBmaintenanceSafari Web Extension + Node.js MCP bridge giving Claude Desktop full control over Safari — navigate, read pages, click elements, fill forms, and manage tabs. No Playwright or WebDriver dependency.4131MIT