Skip to main content
Glama
README.md
<p align="center"><img src="docs/icon.png" width="96" height="96" alt=""></p>

<h1 align="center">Safari Sidekick</h1>

<p align="center">Ask Claude to do things in Safari.</p>

<p align="center">
  <a href="https://philipvox.github.io/safari-mcp/"><b>Download for Mac</b></a>
  &nbsp;&nbsp;
  <a href="https://github.com/philipvox/safari-mcp/releases">Releases</a>
  &nbsp;&nbsp;
  <a href="#for-developers">MCP server and CLI</a>
</p>

<p align="center">
  <picture>
    <source srcset="docs/chat-dark.png" media="(prefers-color-scheme: dark)">
    <img src="docs/chat-light.png" width="340" alt="The Safari Sidekick window. The user asked for today's featured article on Wikipedia. Below are the steps Claude took, then its two-sentence answer.">
  </picture>
</p>

Tell Claude what you want done on the web. It opens the pages, reads them, clicks and fills in forms in a Safari window beside the chat, and tells you what it found. It uses your normal Safari, so it is signed in wherever you are.

Or open it as a panel on the page you are reading. Ask about the page or the text you highlighted, and have Claude click, type and fill in forms right there.

Safari Sidekick is a free Mac app for Macs with Apple silicon and macOS 13 or newer. It needs a Claude account (Pro or Max) or an Anthropic API key. It is an independent project, not made or endorsed by Anthropic or Apple.

**It is in beta.** It works day to day, but it has had few users so far. If something goes wrong, choose **Report a Problem…** from the Safari Sidekick menu, or [open an issue](https://github.com/philipvox/safari-mcp/issues). Changes are listed in the [changelog](CHANGELOG.md).

## Install

[Download Safari Sidekick](https://github.com/philipvox/safari-mcp/releases/latest/download/Safari-Sidekick.zip), open the zip, and drag the app to your Applications folder. The app is signed and notarized by Apple.

With Homebrew:

```bash
brew tap philipvox/tap
brew trust philipvox/tap
brew install --cask philipvox/tap/safari-sidekick
```

The `trust` line is Homebrew's own check for recipes from outside its main collection.

## First run

The app walks you through setup in its own window. It takes about five minutes.

<table>
  <tr>
    <td width="50%" valign="top">
      <picture>
        <source srcset="docs/setup-install-dark.png" media="(prefers-color-scheme: dark)">
        <img src="docs/setup-install-light.png" alt="The Install Claude Code screen, with one Install button.">
      </picture>
    </td>
    <td width="50%" valign="top">
      <picture>
        <source srcset="docs/setup-signin-dark.png" media="(prefers-color-scheme: dark)">
        <img src="docs/setup-signin-light.png" alt="The Use your Claude Code sign-in screen, with a Sign in to Claude Code button and a Use an API key instead button.">
      </picture>
    </td>
  </tr>
  <tr>
    <td valign="top">1. Install Claude Code, Anthropic's free program that the app talks to Claude through. One button, no password.</td>
    <td valign="top">2. Sign in to Claude Code with your own Claude account, on Anthropic's page in your browser. Or paste an Anthropic API key, which is kept in your Mac's keychain.</td>
  </tr>
</table>

3. Let the app control Safari. macOS asks once, and the app shows you the one Safari setting to switch on ("Allow JavaScript from Apple Events").

After that, type what you want done. Safari opens beside the app and Claude works in it.

Screenshots are optional. Claude can read and use pages without them, but to let it see a page as an image, choose **Allow Screenshots…** from the Safari Sidekick menu and switch Safari Sidekick on in the list that opens.

## Your account and your data

- **Claude plan:** you sign in to Anthropic's own Claude Code, on your Mac, with your own account. Safari Sidekick runs that Claude Code for you and never sees your password or sign-in token. What you ask uses your plan's normal limits, which Anthropic sets for ordinary personal use. Each person signs in with their own account: do not share one sign-in between people.
- **API key:** for heavier or automated use, use an Anthropic API key. That is Anthropic's supported route for apps and scripts. Usage is billed by Anthropic, and the key stays in your keychain.
- **Your browsing:** Claude works in its own Safari window, or in the tab you opened the panel on, and never touches your other tabs. The pages it reads are sent to Claude as part of your conversation.
- **Updates:** when it starts, the app asks GitHub whether a newer version exists, and shows a line in the window if so. Nothing about you is sent. It asks before it submits a form, sends a message, buys or deletes anything.

## Ask about the page you are on

<img src="docs/sidebar.png" width="300" align="right" alt="The Safari Sidekick panel on example.com. The user asked what the highlighted words mean and to click the link. Claude explained, clicked Learn more, and reported the new page's title.">

The app comes with a Safari toolbar button. Turn it on once: choose **Add Toolbar Button to Safari…** from the Safari Sidekick menu, or open Safari's Settings, click Extensions, and tick Safari Sidekick.

Then click the button on any page. A panel opens on the right of the page:

- The page goes with your message, so you can ask "summarize this" or "what does this clause mean" without copying anything.
- Text you highlight on the page goes with it too.
- Ask Claude to do something on the page, such as filling in a long form, and it works in that tab while you watch. It never closes your tab.
- Click the button again, or the close button, to hide the panel. The conversation stays.

The panel reads the page only when you click the button, and only that tab. The extension has no standing access to any website.

In the app's own window, **Add current page** does the same with the page in your front Safari window.

<br clear="right">

## For developers

The engine behind the app is `safari-mcp`, which lets Claude drive the Safari you already use. It can open pages, read them, click, type, fill forms, take screenshots, and read console and network logs, in a Safari window that shares your logins.

It is an MCP server and a command line tool for macOS. It has the same tools, with the same names and parameters, as Anthropic's Claude in Chrome, so prompts and habits carry over. It works with a Claude subscription through Claude Code, and with any other MCP client. An API key is optional.

The engine needs no browser extension. It talks to Safari through AppleScript, has no npm dependencies, and runs straight from GitHub.

The rest of this page covers the MCP server and command line tool.

## Requirements

- macOS with Safari
- Node 18 or newer
- Claude Code, if you want to use it with a Claude subscription

## Setup

1. Allow scripts to run JavaScript in Safari. Open Safari, then Settings, then Advanced, and tick "Show features for web developers". Then open Settings, Developer, and tick "Allow JavaScript from Apple Events".

2. Add the server to Claude Code:

   ```bash
   claude mcp add safari --scope user -- npx -y github:philipvox/safari-mcp serve
   ```

3. Check that everything works:

   ```bash
   npx -y github:philipvox/safari-mcp doctor
   ```

The first time, macOS asks whether your terminal may control Safari. Say yes. Screenshots also need Screen Recording permission for the app that runs the server (System Settings, Privacy & Security, Screen & System Audio Recording). Everything except screenshots works without it.

Now start Claude Code and ask for something like "open news.ycombinator.com in Safari and summarize the top five stories".

For other MCP clients, use this configuration:

```json
{
  "mcpServers": {
    "safari": { "command": "npx", "args": ["-y", "github:philipvox/safari-mcp", "serve"] }
  }
}
```

## Chat with Claude in Safari

```bash
npx -y github:philipvox/safari-mcp chat
```

This opens a chat page in a Safari window on the left, and Claude browses in a second window beside it. Type what you want done. Each step Claude takes ("Opened example.com", "Clicked", "Read the page text") appears in the chat as it happens, followed by the answer. Leave the command running while you chat, and press Ctrl-C to quit.

The chat runs on your Claude account through Claude Code:

- If Claude Code is signed in, the chat shows your plan and is ready to use.
- If it is not, the page shows a "Sign in" button. It starts Claude Code's own sign-in (`claude auth login`) in a Terminal window, which opens the normal Claude sign-in page. The chat continues by itself once you finish.
- To bill an API key instead, set `ANTHROPIC_API_KEY` before starting the chat.
- To give the chat its own sign-in, separate from the one Claude Code uses, start it with `--profile <name>`. A new profile starts signed out, so this is also how to use a second Claude account or to try the sign-in flow without signing out of Claude Code. Profiles are kept in `~/Library/Application Support/safari-mcp/profiles`.

This project never signs in to claude.ai itself, and never sees or stores your credentials. It runs the official Claude Code on your Mac, signed in with your own account. Anthropic's rules for Claude Code allow you to sign in to Claude Code with your own subscription, and do not allow developers to offer Claude login in their own apps or route other people's requests through plan credentials. Use your plan for your own ordinary use, and an API key for anything heavier or shared. See Anthropic's [Claude Code legal and compliance page](https://code.claude.com/docs/en/legal-and-compliance) for the current wording.

In chat, Claude can use only the browser tools. It has no access to your files or shell, and none of your personal Claude Code settings, hooks or memory are loaded. It is told to ask before submitting forms, sending messages, buying or deleting anything.

The chat page is served from `127.0.0.1` on a random port and needs a one-time token that is part of its address, so other sites and other machines cannot talk to it.

## How it behaves

Each session gets its own Safari window, the way Claude in Chrome gets its own tab group. The window uses your normal Safari profile, so sites you are signed in to stay signed in. Your other windows and tabs are never touched.

While Claude acts on a page, a "Claude is working here" bar shows at the top of it, with a soft glow around the page. Press its Stop button to stop Claude at its next step. The bar is left out of what Claude reads, clicks and screenshots.

The window opens behind whatever you are working in. The server never brings Safari to the front and never takes keyboard focus, so you can keep working while Claude uses the browser.

### Keep a corner of the window visible

Safari stops painting a window that is completely hidden behind other windows, and slows its timers down. This is a macOS power-saving behaviour, and it affects two things:

- Screenshots of a fully covered window come out blank or out of date. The tool result says so when it happens.
- Pages that depend on animation frames (lazy-loaded images, animated menus) can stall until the window is visible again.

Reading pages, finding elements, clicking, typing, forms and JavaScript all keep working in a covered window.

If any part of the window is visible, even a thin strip at the edge, everything works normally. When the window is fully covered and there is free space on any screen, the server slides the window just far enough for a corner to show there. It cannot do that if another app fills every screen. In that case you can either resize your front window a little, or start the server with `SAFARI_MCP_FOREGROUND=auto`, which lets it bring Safari forward for a moment to take a screenshot and then return to the app you were in. That option is off by default because it interrupts typing.

## Tools

| Tool | What it does |
|---|---|
| `tabs_context_mcp` | Lists the session's tabs. Opens the window with `createIfEmpty` |
| `tabs_create_mcp`, `tabs_close_mcp` | Open and close tabs |
| `navigate` | Go to a URL, or back and forward |
| `read_page` | Outline of the page with a reference ID for each element |
| `find` | Find elements by description, such as "search box" |
| `get_page_text` | Readable text of the page, preferring the main article |
| `computer` | Click, double click, right click, hover, drag, type, press keys, scroll, screenshot, zoom, wait |
| `form_input` | Set a field, checkbox, radio button or dropdown by reference |
| `javascript_tool` | Run JavaScript in the page. Top-level `await` works |
| `read_console_messages` | Console output and uncaught errors |
| `read_network_requests` | Requests the page has made |
| `file_upload`, `upload_image` | Attach files or a screenshot to a file input or drop target |
| `resize_window` | Resize the window to test layouts |
| `gif_creator` | Record the session as an animated GIF |
| `browser_batch` | Run several of the above in one call |
| `list_connected_browsers`, `select_browser`, `switch_browser` | Present for compatibility. There is one browser: this Mac's Safari |

Run `safari-mcp tools <name>` to see a tool's parameters.

## Command line

Every tool is also a command. State is kept between commands in a named session.

```bash
safari-mcp navigate --url example.com
safari-mcp find --tabId 1 --query "learn more link"
safari-mcp computer --tabId 1 --action left_click --ref ref_8
safari-mcp computer --tabId 1 --action screenshot --out page.jpg
safari-mcp javascript_tool --tabId 1 --action javascript_exec --text "document.title"
safari-mcp close
```

Add `--session work` to keep a second set of tabs apart from the default one. Add `--raw` for the full MCP result as JSON. Coordinates can be written as `--coordinate 400,300`.

If you installed nothing, prefix these with `npx -y github:philipvox/safari-mcp`, or install the command once with `npm install -g github:philipvox/safari-mcp`.

### Give Claude a task from the shell

```bash
safari-mcp run "open the Hacker News front page and list the top three titles"
```

This starts Claude Code in headless mode with only the Safari tools allowed, so it uses your Claude subscription login.

To use the Anthropic API instead, clone the repository, run `npm install @anthropic-ai/sdk`, set `ANTHROPIC_API_KEY`, and add `--api`:

```bash
safari-mcp run --api "open example.com and tell me what it says"
```

The API mode uses `claude-opus-5-5` unless you pass `--model`. Its tool loop is covered by an offline test with a stand-in client, but it has not yet been run against the live API, so treat it as experimental.

## Differences from Claude in Chrome

Chrome gives extensions a debugger interface. Safari has no equivalent, so some things work differently here.

- Input is simulated with script events inside the page. Nearly all sites accept that. A few that insist on hardware input (some banking and anti-bot pages) may ignore it.
- CSS `:hover` styles do not apply, because the real pointer does not move. Menus opened by script events do open.
- Native dropdowns, file pickers and the clipboard cannot be driven. Use `form_input` for a `<select>` and `file_upload` for files.
- `alert`, `confirm` and `prompt` are answered automatically, because a blocking dialog would freeze Safari's scripting channel. `confirm` is declined by default. Tool results say when this happened.
- Console and network capture is installed by the server when it first touches a page. For pages opened with `navigate` that is during loading, but messages from the first fraction of a second can be missed. `read_network_requests` still lists every resource the page loaded, from the browser's own timing log. Method and status are known for `fetch` and XHR calls made after capture began.
- `find` matches your words against element text, labels, roles and attributes. Chrome's version uses a language model. Use words that appear on the page, or name the kind of control.
- Content inside cross-origin iframes cannot be read or clicked.
- Pages that cannot run scripts (PDFs, Safari's error pages, the start page) can be navigated away from but not read.
- GIF recordings include click markers, drag paths and a progress bar, but no text labels or watermark.

## Safety

Claude acts in your real browser with your real sessions, so the same care applies as with any browser agent.

- Text on web pages is data, not instructions. The server tells the model so, but you should still watch what it does on sites that matter.
- Limit where it can go with `SAFARI_MCP_ALLOWED_DOMAINS` (only these sites) or `SAFARI_MCP_BLOCKED_DOMAINS` (never these sites). Subdomains are included.
- `file_upload` only reads files inside the server's working directory or folders you list in `SAFARI_MCP_UPLOAD_DIRS`. This stops a page from talking the model into uploading files from elsewhere on your Mac.
- `file:` URLs are refused unless you set `SAFARI_MCP_ALLOW_FILE_URLS=1`.
- Sensitive query string values are shown as `REDACTED` in network listings.

## Settings

Set these as environment variables on the server (for Claude Code: `claude mcp add safari -e NAME=value ...`).

| Variable | Meaning |
|---|---|
| `SAFARI_MCP_ALLOWED_DOMAINS` | Comma-separated sites the tools may touch. Default: any |
| `SAFARI_MCP_BLOCKED_DOMAINS` | Comma-separated sites the tools must not touch |
| `SAFARI_MCP_UPLOAD_DIRS` | Extra folders `file_upload` may read, separated by colons |
| `SAFARI_MCP_OUTPUT_DIR` | Where saved screenshots and GIFs go. Default: `~/Downloads` |
| `SAFARI_MCP_DIALOGS=accept` | Answer `confirm` with OK instead of Cancel |
| `SAFARI_MCP_FOREGROUND=auto` | Allow bringing Safari forward briefly when a screenshot needs it |
| `SAFARI_MCP_WINDOW_SIZE` | Size of the session window. Default: `1280x900` |
| `SAFARI_MCP_ALLOW_FILE_URLS=1` | Allow `file:` URLs |
| `SAFARI_MCP_INDICATOR=0` | Do not show the "Claude is working here" bar on pages Claude is using |

## Troubleshooting

Run `safari-mcp doctor` first. It checks each requirement and says how to fix what fails.

- "Safari is blocking scripted JavaScript": do step 1 of the setup.
- "macOS has not allowed this program to control Safari": open System Settings, Privacy & Security, Automation, and switch on Safari for your terminal or editor.
- Blank screenshots: see "Keep a corner of the window visible" above. If screenshots fail outright, grant Screen Recording permission and restart the app that runs the server.
- "Safari did not answer in time": a print dialog or a "leave this page?" prompt is probably open in the session window. Dismiss it.

## Development

To build the app yourself, run `app/build.sh`. It needs the Xcode command line tools and an official Node build.


```bash
git clone https://github.com/philipvox/safari-mcp
cd safari-mcp
npm test              # unit tests, no browser needed
npm run test:safari   # drives real Safari against a local test page
```

The Safari tests open their own window, use only a local test server, and close the window when they finish. Two of them check screenshot pixels and are skipped when the test window is completely covered.

How the pieces fit:

- `src/safari.js` and `src/osa.js`: AppleScript calls for windows, tabs and running JavaScript
- `src/runtime.js`: the script injected into each page (element references, simulated input, console and network capture). It never uses `eval`, so it works under strict Content Security Policies
- `src/session.js`: the session window, stable tab IDs, navigation waits, screenshots
- `src/tools.js`: the tool definitions
- `src/mcp.js`: the MCP server (JSON-RPC over stdio)
- `src/cli.js`, `src/agent.js`: the command line and the `run` command
- `src/chat.js`, `src/chat.html`: the chat server and page
- `app/`: the Mac app, a small Swift window around the chat page, with Node and this engine inside
- `app/extension/`: the Safari extension inside the app, a toolbar button that opens it
- `app/homebrew/`: the Homebrew recipe, copied to github.com/philipvox/homebrew-tap on each release
- `docs/`: the download page, published with GitHub Pages
- `src/png.js`, `src/gif.js`: image decoding, scaling and GIF encoding without native modules

## Licence

MIT. See [LICENSE](LICENSE). The Mac app also contains Node.js, under its own MIT licence; see [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). Claude Code is not included: the app downloads it from Anthropic, under Anthropic's terms.