Skip to main content
Glama
README.md
# vivaldi-mcp

An MCP server that lets Claude (or any MCP client) work in **your own Vivaldi** on macOS: your
profile, your logins, in a background tab. It reads pages, clicks, fills forms, runs JavaScript
and takes screenshots, through AppleScript. No browser extension, no debug port, no dependencies,
nothing running when your MCP client is closed.

Made because the Claude in Chrome extension does not work in Vivaldi.

**macOS only.** The server talks to Vivaldi through AppleScript, which Windows and Linux do not
have (see [Other systems](#other-systems)).

## Install

Needs macOS, Vivaldi and Node.js 18 or newer. No git needed.

1. In Vivaldi: **Settings > Privacy and Security > Apple Events**, turn on **Allow JavaScript from
   Apple Events**.

2. Add the server to your MCP client. Pick one way.

   **Without downloading anything**: `npx` (comes with Node.js) fetches the code from GitHub at the
   first start and keeps it.

   Claude Code:

   ```bash
   claude mcp add vivaldi -s user -- npx -y https://github.com/TheLonelyUnicorn/vivaldi-mcp/archive/refs/tags/v0.2.1.tar.gz
   ```

   Claude Desktop and other clients (`mcpServers` in their configuration file):

   ```json
   {
     "mcpServers": {
       "vivaldi": {
         "command": "npx",
         "args": ["-y", "https://github.com/TheLonelyUnicorn/vivaldi-mcp/archive/refs/tags/v0.2.1.tar.gz"]
       }
     }
   }
   ```

   To update, put the newer version number in the address.

   **From a folder**: download
   [the ZIP](https://github.com/TheLonelyUnicorn/vivaldi-mcp/archive/refs/heads/main.zip) and unpack
   it (or `git clone https://github.com/TheLonelyUnicorn/vivaldi-mcp.git`), then give your client
   the full path to `server.mjs`:

   ```bash
   claude mcp add vivaldi -s user -- node /full/path/to/vivaldi-mcp/server.mjs
   ```

   ```json
   {
     "mcpServers": {
       "vivaldi": { "command": "node", "args": ["/full/path/to/vivaldi-mcp/server.mjs"] }
     }
   }
   ```

   To update, download the ZIP again (or `git pull`) and restart your MCP client.

3. The first time a tool runs, macOS asks whether the app running your MCP client may control
   Vivaldi. Allow it (System Settings > Privacy & Security > Automation shows it afterwards).
   Screenshots in `window` mode also need Screen Recording permission, once.

## First use: Claude's tab

Vivaldi brings itself to the front of your screen whenever a new tab is made, however the tab is
made. So the server makes a tab once and keeps it: when a job is done, the tab is not closed but
left on a page titled **Claude · free**, and the next job works in that tab. Nothing moves on your
screen then.

You can pin that tab so it stays out of the way. Two clicks, and Vivaldi offers no way to do them
from outside:

1. Right-click the tab > **Pin Tab**.
2. Right-click it again > untick **Restrict Pinned Tab to Current Site**. Without this, Vivaldi
   opens every page from a pinned tab in a new tab in front of yours. (For all pinned tabs at once:
   Settings > Tabs > Pinned Tabs > Restrict Pinned Tabs to Current Site.)

On the first use the server tells the assistant to pass this on, and the tab's own page says it
too (in German in a German Vivaldi, where the entries are "Tab anheften" and "Links zu anderen
Domains in neuen Tabs öffnen"). If the tab is pinned and still restricted, the server notices,
works in the tab Vivaldi made instead, puts your tab and app back in front, and says what to
untick.

You can close Claude's tab at any time; the next job makes a new one (Vivaldi comes to the front
once).

## Tools

| Tool | What it does |
| --- | --- |
| `vivaldi_tabs` | Lists all open tabs. |
| `vivaldi_open` | A page in a background tab: Claude's free tab, or a new tab when there is none. |
| `vivaldi_navigate` | Another address in a tab, or `back`. |
| `vivaldi_snapshot` | Headings and interactive elements with numbers for click and fill. |
| `vivaldi_read` | The visible text of a tab or of one element. |
| `vivaldi_click` | Clicks by number, CSS selector or visible text. |
| `vivaldi_fill` | Inputs, selects, checkboxes, contenteditable (React-safe). Never password fields. |
| `vivaldi_scroll`, `vivaldi_wait` | Scrolls; waits for a selector or a text. |
| `vivaldi_js` | Runs JavaScript in the page (expression or function body, `await` works). |
| `vivaldi_screenshot` | A picture of a tab (see below). |
| `vivaldi_show` | Brings a tab and Vivaldi to the front. The tab is yours from then on. |
| `vivaldi_close` | Ends a job: the tab becomes the free tab again. |

Rules the server keeps:

- Clicking, filling, navigating, JavaScript and closing work only in tabs the server opened. Your
  own tabs can be read; acting in one needs `any_tab: true`, which the assistant is told to use
  only when you ask for it.
- Password fields are never filled. If a page wants a sign-in, sign in yourself in Vivaldi.
- Only `http(s)`, `file` and `data` addresses and `about:blank` are opened. The browser's own pages
  (`vivaldi://`, `chrome://`, `chrome-extension://`) are refused: they cannot be scripted, and some
  of them quit or crash the browser.

## Focus

Measured with Vivaldi 8.3 on macOS: Vivaldi activates itself 0.1 to 0.4 s after a new tab exists
(AppleScript `make new tab`, `open -g`, a synthetic cmd-click alike). Nothing else does that:
setting a tab's address, JavaScript, switching the active tab, closing. Handing the focus back is
not enough, because the Vivaldi window stays above your other windows. Hence the free tab.

The rule for which tab a job works in lives in `tabs.mjs` only, for the server and for your own
scripts:

```bash
node tabs.mjs open https://example.com   # prints a tab id
node tabs.mjs close <tab id>             # "parked" (free tab again) or "closed"
```

- The free tab is found by its address (a `data:` page with the marker `vivaldi-mcp-free-tab`),
  so it survives sessions and a restart of Vivaldi. A tab you are looking at (the active tab of its
  window) is never taken.
- `~/Library/Caches/vivaldi-mcp/tab-<id>` holds `{ pid, home, kept }` for every tab a job works in.
  `pid`: two jobs never take the same tab, and a tab whose job is gone (a session that ended
  without `vivaldi_close`) is taken by the next job. `home`: the tab was the free tab when taken;
  a home tab is always parked, never closed. An extra tab, made while the home tab was in use, is
  closed for real. `kept`: the tab was shown to you with `vivaldi_show`, no later job takes it.
- When a new tab is needed, the server waits until Vivaldi really is in front, hands the focus
  back to your app and checks that it holds.
- Tab stacks cannot be set from outside: Vivaldi's AppleScript dictionary (Chrome's) knows neither
  stacks nor pinning, and `make new tab at after tab n` is ignored (the tab lands at the end).

`node focus.mjs` puts Finder in front, runs open, navigate, read and close through two servers and
reports for each step whether Vivaldi came to the front.

## Screenshots

- `mode: "render"` (default): html-to-image (MIT, in `vendor/`, injected into the page) redraws the
  visible part, the whole page (`full`) or one `selector` inside the tab. Stays in the background,
  but is approximate: images and icons from other servers that refuse CORS come out as grey boxes.
  About 1 s on small pages, 4 to 15 s on large ones.
- `mode: "window"`: real pixels. The tab becomes the active tab of its window and Vivaldi comes to
  the front for 1 to 2 s; `screencapture -l <window>` takes only the Vivaldi window; then your tab
  and app come back. Before the capture the server checks that its tab really is the one in front,
  else nothing is captured.

## Limits

- No console or network logs, no file uploads.
- Clicks are synthetic events (`isTrusted` is false): strict sites may ignore them.
- Frames from other origins are not reachable.
- Pages opening pop-ups or new tabs by script are stopped by Vivaldi's pop-up blocker.

## Other systems

Windows and Linux are not supported, and there is no small step to get there. The two ways to
drive a Chromium browser without AppleScript both change what this tool is:

- The DevTools debug port (`--remote-debugging-port`): since Chromium 136 it is refused for the
  default profile, and the same check is compiled into Vivaldi (seen in 8.3). It would only reach a
  second profile without your logins.
- A browser extension with a local helper: works with your profile on every system, but has to be
  installed in Vivaldi and is a different program from this one.

## Files

- `server.mjs`: MCP over stdio (JSON-RPC), the tool definitions.
- `tabs.mjs`: which tab a job works in (free tab, claims), the AppleScript call; also a command line.
- `vivaldi.applescript`: the tab operations (`osascript vivaldi.applescript <op> ...`).
- `page.js`: helpers injected into the page (`window.__vmcp`).
- `vendor/html-to-image-1.11.13.js` and its licence (sha256
  a90b42909d80964269ef6d5f3d1e4a5a7e2a4c263a5d2a76a9e7151901343262).
- `smoke.mjs`: `node smoke.mjs` opens example.com and httpbin.org/forms/post in a background tab,
  reads, clicks, fills (nothing is submitted) and gives the tab back.
- `focus.mjs`: the focus test above.
- `shot.mjs`: `node shot.mjs <url> <render|window|both> <out-prefix> [full]` saves screenshots.

## Licence

Apache License 2.0, see [LICENSE](LICENSE) and [NOTICE](NOTICE). html-to-image in `vendor/` is
under the MIT License.