Skip to main content
Glama
zhuhroscar-tech

safari-mcp-server

README.md
[![English](https://img.shields.io/badge/English-555555?style=flat)](README.md) [![简体中文](https://img.shields.io/badge/简体中文-555555?style=flat)](README.zh-CN.md)

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

```bash
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.

## Connect an MCP host

For hosts using `mcpServers` configuration:

```json
{
  "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

```bash
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.

```python
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](docs/images/example-output.png) · [Demo video](docs/demo.mp4)

```bash
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](.github/workflows/ci.yml) tests mocked Safari interaction and packaging; it does not establish live Safari behavior. [API implementation](src/safari_mcp/core.py) · [Release history](CHANGELOG.md) · [MIT license](LICENSE)

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

ActivityMaintained
ResponsivenessNo issues