Skip to main content
Glama
safari-mcp
by tszaks

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) or full_dom content, or get markdown, raw HTML, links, images, the current selection or a summary-ready extract.

  • Playwright-style snapshots. safari_snapshot_page returns 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 safaridriver used for screenshots.

Related MCP server: Safari MCP Server

Requirements

  • macOS with Safari at /Applications/Safari.app

  • Node.js 20 or later

  • In Safari: the Develop menu and Allow JavaScript from Apple Events turned on

  • Optional, for screenshots: Allow remote automation in 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.app

Then 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 build

The 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.js

Codex

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

safari_get_active_tab

URL and title of the active tab

safari_find_tab

Find open tabs by URL or title substring

safari_list_tabs

List tabs across all windows, with a private flag per window

safari_list_windows

List windows and their tabs

safari_open_url

Navigate the active tab to a URL (no new tab or window)

safari_new_tab

Open a new tab in the front window

safari_close_tab

Close a tab

safari_close_tabs

Close several tabs in a window

safari_activate_tab

Focus a tab

safari_activate_window

Bring a window to the front

safari_reload_tab

Reload a tab

safari_go_back

Go back in a tab

safari_go_forward

Go forward in a tab

safari_get_page_content

Read page content (visible, readability or full_dom)

safari_get_page_markdown

Page content as markdown

safari_snapshot_page

Structured page snapshot with actionable elements

safari_get_page_html

Full page HTML

safari_get_selection

The selected text

safari_extract_links

Links on the page

safari_extract_images

Images on the page

safari_find_in_page

Find text occurrences in the page

safari_summarize_page

Summary-ready page content

safari_run_javascript

Run JavaScript in the page

safari_query_elements

Query DOM elements

safari_click_element

Click an element, with interactability checks

safari_type_into_element

Type text into an element

safari_submit_form

Submit a form

safari_scroll_page

Scroll the page

safari_wait_for_element

Wait for an element to appear

safari_wait_for_navigation

Wait for navigation to finish loading

safari_wait_for_text

Wait for text to appear or disappear

safari_list_forms

List forms and their fields

safari_screenshot_visible_area

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 Events is 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 test

npm 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

MIT

Available Tools

33 tools
safari_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_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_navigationC

Wait for the current Safari page to navigate and finish loading.

Inputs: tab_index, timeout_ms, interval_ms, window_index.

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

    C2.7/5.0

    Scored across 33 tools

    Disambiguation3/5

    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.

    Naming Consistency5/5

    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.

    Tool Count2/5

    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.

    Completeness3/5

    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

    ActivitySlowing
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      Provides 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.
      13
      9 npm
      33
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables 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
    • F
      license
      Not graded
      quality
      B
      maintenance
      Lets 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.
      -