Skip to main content
Glama
safari-mcp-server

safari-mcp-server

English 简体中文

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:

  1. Allow the launching terminal/app to control Safari under System Settings → Privacy & Security → Automation when prompted.

  2. 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 1

Targeted 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

Example output · Demo video

python -m pip install -e ".[dev]"
python -m pytest -v
# Optional: real Safari; requires permissions and an open browser
python tests/e2e_mcp_roundtrip.py

CI tests mocked Safari interaction and packaging; it does not establish live Safari behavior. API implementation · Release history · MIT license

Available Tools

9 tools
safari_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

    A3.7/5.0

    Scored across 9 tools

    Disambiguation5/5

    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.

    Naming Consistency4/5

    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.

    Tool Count5/5

    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.

    Completeness4/5

    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

    ActivityNo data
    ResponsivenessSyncing

    Related MCP Connectors

    Related MCP Servers

    • -
      license
      A
      quality
      Not graded
      maintenance
      A server that provides AI assistants programmatic control of Safari browser on macOS for web automation, testing, and debugging.
      16
      1
      -
    • A
      license
      A
      quality
      C
      maintenance
      Enables visual web access and browser automation through Safari, with tools for navigation, screenshots, element interaction, and tab management.
      17
      19 npm
      BSD 3-Clause
    • A
      license
      A
      quality
      B
      maintenance
      Safari 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.
      4
      13
      1
      MIT