safari-mcp
English | 简体中文
Let Claude drive Safari on macOS. A Claude Code plugin wrapping a zero-dependency MCP server that controls your real Safari — with your logged-in sessions — through Apple Events (osascript / JXA).
No Xcode, no Safari extension, no npm install.
Unofficial project. Not affiliated with Anthropic or Apple.
Requirements
- macOS with Safari
- Node.js 18 or later
- An MCP client: Claude Code, Claude Desktop, or any other
Tools
| Tool | What it does |
|---|
tabs_list | List every window and tab |
tab_open / tab_select / tab_close | Open, switch to, or close a tab |
navigate | Load a URL, or go back / forward / reload, and wait for the page to load |
get_page_text | Visible text of the page, optionally limited to a CSS selector |
read_page | Outline of the page; interactive elements carry a [ref_N] id |
find | Search elements by text and get their refs |
click | Click by ref, CSS selector, or viewport coordinates (right-click and double-click supported) |
type | Fill inputs, textareas and rich-text editors, pick <select> options, set checkboxes; optionally press Enter |
press_key | Send a key to an element |
scroll | Scroll the page or a container, or bring an element into view |
wait_for | Wait for an element or text to appear or disappear |
run_javascript | Run JavaScript in the page (await supported) |
screenshot | Capture the tab; when possible the toolbar is cropped off so image pixels map to click coordinates |
Install
As a Claude Code plugin
claude plugin marketplace add KristianLi/safari-mcp
claude plugin install safari@safari-mcp
This installs the MCP server and a skill that teaches Claude how to use it.
As a plain MCP server
Clone the repository anywhere, then point your client at server/index.mjs.
Claude Code:
claude mcp add --scope user safari -- node /absolute/path/to/safari-mcp/server/index.mjs
Claude Desktop — add this to ~/Library/Application Support/Claude/claude_desktop_config.json, then quit and reopen the app:
{
"mcpServers": {
"safari": {
"command": "node",
"args": ["/absolute/path/to/safari-mcp/server/index.mjs"]
}
}
}
If the app cannot find node, use its absolute path (for example /opt/homebrew/bin/node).
Permissions you have to grant
These are macOS and Safari security settings. The server never changes them; when one is missing, the affected tool returns the steps below instead.
- Automation. On the first call macOS asks whether the app running Claude may control Safari. Allow it. You can review this later in System Settings ▸ Privacy & Security ▸ Automation.
- Allow JavaScript from Apple Events. Safari ▸ Settings ▸ Advanced ▸ enable "Show features for web developers", then Settings ▸ Developer ▸ enable "Allow JavaScript from Apple Events". Needed by
read_page, find, click, type, press_key, scroll, wait_for and run_javascript.
- Screen Recording (only for
screenshot). System Settings ▸ Privacy & Security ▸ Screen & System Audio Recording: enable the app running Claude, then restart it.
Without 2 and 3, tabs_list, tab_open, tab_select, tab_close, navigate and get_page_text still work.
Security
Read this before turning the settings on.
- The power comes from the two macOS/Safari permissions, not from this server. Once Automation and "Allow JavaScript from Apple Events" are both on, any script run by the authorized app can read and act on every page in your Safari, including sites you are logged in to. Turn the Safari setting off when you are not using it.
- Web pages are untrusted input. A page can contain text written to manipulate an AI agent. The bundled skill and the server instructions tell Claude to treat page content as data and to ask before submitting forms, sending messages, purchasing or deleting — but you should still watch what it does on sites that matter.
read_page never returns the contents of password fields, and tab_close refuses to act when it has no explicit target.
How it works
Claude ──MCP/stdio──▶ server/index.mjs ──osascript──▶ server/bridge.jxa.js ──Apple Events──▶ Safari
└─ do JavaScript ─▶ server/page.mjs (runs in the page)
server/index.mjs — MCP protocol and tool definitions. Tool calls run one at a time.
server/bridge.jxa.js — tab management, page text, and do JavaScript.
server/page.mjs — code that runs inside the page: builds the element outline and refs, synthesizes clicks and input.
server/png.mjs — crops the browser toolbar off window screenshots.
skills/safari/SKILL.md — the skill that teaches Claude the workflow.