safari-mcp 2.0.0 โ 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +115 -9
- package/extension/background.js +1968 -0
- package/extension/content.js +23 -0
- package/extension/images/icon-128.png +0 -0
- package/extension/images/icon-48.png +0 -0
- package/extension/images/icon-96.png +0 -0
- package/extension/manifest.json +27 -0
- package/extension/popup/popup.html +78 -0
- package/extension/popup/popup.js +57 -0
- package/glama.json +11 -0
- package/index.js +755 -122
- package/package.json +20 -3
- package/safari-helper +0 -0
- package/safari-helper.swift +210 -0
- package/safari.js +1494 -346
- package/xcode/Safari MCP/Safari MCP.xcodeproj/project.pbxproj +991 -0
- package/xcode/Safari MCP/Safari MCP.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/xcode/Safari MCP/Shared (App)/Assets.xcassets/AccentColor.colorset/Contents.json +11 -0
- package/xcode/Safari MCP/Shared (App)/Assets.xcassets/AppIcon.appiconset/Contents.json +98 -0
- package/xcode/Safari MCP/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-128@1x.png +0 -0
- package/xcode/Safari MCP/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-128@2x.png +0 -0
- package/xcode/Safari MCP/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-16@1x.png +0 -0
- package/xcode/Safari MCP/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-16@2x.png +0 -0
- package/xcode/Safari MCP/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-256@1x.png +0 -0
- package/xcode/Safari MCP/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-256@2x.png +0 -0
- package/xcode/Safari MCP/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-32@1x.png +0 -0
- package/xcode/Safari MCP/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-32@2x.png +0 -0
- package/xcode/Safari MCP/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-512@1x.png +0 -0
- package/xcode/Safari MCP/Shared (App)/Assets.xcassets/AppIcon.appiconset/mac-icon-512@2x.png +0 -0
- package/xcode/Safari MCP/Shared (App)/Assets.xcassets/AppIcon.appiconset/universal-icon-1024@1x.png +0 -0
- package/xcode/Safari MCP/Shared (App)/Assets.xcassets/Contents.json +6 -0
- package/xcode/Safari MCP/Shared (App)/Assets.xcassets/LargeIcon.imageset/Contents.json +21 -0
- package/xcode/Safari MCP/Shared (App)/Assets.xcassets/LargeIcon.imageset/icon-128.png +0 -0
- package/xcode/Safari MCP/Shared (App)/Resources/Base.lproj/Main.html +20 -0
- package/xcode/Safari MCP/Shared (App)/Resources/Icon.png +0 -0
- package/xcode/Safari MCP/Shared (App)/Resources/Script.js +24 -0
- package/xcode/Safari MCP/Shared (App)/Resources/Style.css +61 -0
- package/xcode/Safari MCP/Shared (App)/ViewController.swift +81 -0
- package/xcode/Safari MCP/Shared (Extension)/SafariWebExtensionHandler.swift +42 -0
- package/xcode/Safari MCP/iOS (App)/AppDelegate.swift +24 -0
- package/xcode/Safari MCP/iOS (App)/Base.lproj/LaunchScreen.storyboard +36 -0
- package/xcode/Safari MCP/iOS (App)/Base.lproj/Main.storyboard +38 -0
- package/xcode/Safari MCP/iOS (App)/Info.plist +27 -0
- package/xcode/Safari MCP/iOS (App)/SceneDelegate.swift +18 -0
- package/xcode/Safari MCP/iOS (Extension)/Info.plist +13 -0
- package/xcode/Safari MCP/macOS (App)/AppDelegate.swift +21 -0
- package/xcode/Safari MCP/macOS (App)/Base.lproj/Main.storyboard +124 -0
- package/xcode/Safari MCP/macOS (App)/Info.plist +8 -0
- package/xcode/Safari MCP/macOS (Extension)/Info.plist +13 -0
- package/social-preview.png +0 -0
package/README.md
CHANGED
|
@@ -1,10 +1,38 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
1
3
|
# ๐ฆ Safari MCP
|
|
2
4
|
|
|
3
|
-
**
|
|
5
|
+
**The only MCP server for Safari โ native browser automation for AI agents.**
|
|
6
|
+
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
[](https://github.com/achiya-automation/safari-mcp/releases)
|
|
9
|
+
[](https://nodejs.org/)
|
|
10
|
+
[](https://www.apple.com/macos/)
|
|
11
|
+
[](https://modelcontextprotocol.io)
|
|
12
|
+
[](https://glama.ai/mcp/servers/achiya-automation/safari-mcp)
|
|
13
|
+
|
|
14
|
+
**80 tools** ยท **Zero dependencies** ยท **~5ms per command** ยท **60% less CPU than Chrome**
|
|
4
15
|
|
|
5
|
-
|
|
16
|
+
[Quick Start](#quick-start) ยท [All 80 Tools](#tools-80) ยท [Why Safari MCP?](#safari-mcp-vs-alternatives) ยท [Architecture](#architecture)
|
|
17
|
+
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
---
|
|
6
21
|
|
|
7
|
-
> **
|
|
22
|
+
> **TL;DR:** Use your real Safari with all your logins, cookies, and sessions. No headless browsers, no Chrome, no Puppeteer. Just pure AppleScript + JavaScript running natively on macOS โ 60% less CPU/heat on Apple Silicon.
|
|
23
|
+
|
|
24
|
+
<details>
|
|
25
|
+
<summary><b>๐ค Why not just use Playwright or Chrome DevTools MCP?</b></summary>
|
|
26
|
+
|
|
27
|
+
| Problem | Safari MCP Solution |
|
|
28
|
+
|---------|-------------------|
|
|
29
|
+
| Chrome DevTools MCP heats up your Mac | Native WebKit โ ~60% less CPU |
|
|
30
|
+
| Playwright launches a new browser without your logins | Uses your **real Safari** with all sessions |
|
|
31
|
+
| Puppeteer requires Chrome + debug port | Zero dependencies โ just AppleScript |
|
|
32
|
+
| Headless browsers can't access your authenticated sessions | Gmail, GitHub, Slack โ already logged in |
|
|
33
|
+
| Browser automation steals window focus | Safari stays in background, never interrupts |
|
|
34
|
+
|
|
35
|
+
</details>
|
|
8
36
|
|
|
9
37
|
---
|
|
10
38
|
|
|
@@ -300,24 +328,80 @@ Add to your MCP client config:
|
|
|
300
328
|
|
|
301
329
|
## Architecture
|
|
302
330
|
|
|
331
|
+
Safari MCP uses a **dual-engine** architecture โ the Extension is preferred for speed and advanced capabilities, with AppleScript as an always-available fallback:
|
|
332
|
+
|
|
303
333
|
```
|
|
304
334
|
Claude/Cursor/AI Agent
|
|
305
335
|
โ MCP Protocol (stdio)
|
|
306
336
|
Safari MCP Server (Node.js)
|
|
307
|
-
โ
|
|
308
|
-
AppleScript
|
|
309
|
-
|
|
310
|
-
|
|
337
|
+
โ โ
|
|
338
|
+
Extension (HTTP) AppleScript + Swift daemon
|
|
339
|
+
(~5-20ms/cmd) (~5ms/cmd, always available)
|
|
340
|
+
โ โ
|
|
341
|
+
Content Script do JavaScript in tab N
|
|
342
|
+
โ โ
|
|
343
|
+
Page DOM โโโโโโโโโโ Page DOM
|
|
311
344
|
```
|
|
312
345
|
|
|
313
346
|
**Key design decisions:**
|
|
314
|
-
- **
|
|
347
|
+
- **Dual engine with automatic fallback** โ Extension is preferred; if not connected, AppleScript handles everything seamlessly
|
|
348
|
+
- **Persistent Swift helper** โ one long-running process instead of spawning per command (16x faster)
|
|
315
349
|
- **Tab-indexed operations** โ all JS runs on a specific tab by index, never steals visual focus
|
|
316
350
|
- **JS-first approach** โ typing, clicking, file upload all use JavaScript events (no System Events keyboard conflicts)
|
|
317
351
|
- **No `activate`** โ Safari is never brought to foreground
|
|
318
352
|
|
|
319
353
|
---
|
|
320
354
|
|
|
355
|
+
## Safari Extension (Optional)
|
|
356
|
+
|
|
357
|
+
The Safari MCP Extension is **optional but recommended**. Without it, ~80% of functionality works via AppleScript alone. The extension adds capabilities that AppleScript cannot provide:
|
|
358
|
+
|
|
359
|
+
### What the Extension Adds
|
|
360
|
+
|
|
361
|
+
| Capability | With Extension | AppleScript Only |
|
|
362
|
+
|-----------|:--------------:|:----------------:|
|
|
363
|
+
| Closed Shadow DOM (Reddit, Web Components) | โ
Full access | โ Invisible |
|
|
364
|
+
| Strict CSP sites | โ
Bypasses via MAIN world | โ Often blocked |
|
|
365
|
+
| React/Vue/Angular state manipulation | โ
Deep (Fiber, ProseMirror) | โ ๏ธ Basic |
|
|
366
|
+
| Loading state detection (spinners, skeletons) | โ
Smart detection | โ No |
|
|
367
|
+
| Dialog handling (alert/confirm) | โ | โ
Only AppleScript |
|
|
368
|
+
| Native OS-level click (CGEvent) | โ | โ
Only AppleScript |
|
|
369
|
+
| PDF export | โ | โ
Only AppleScript |
|
|
370
|
+
|
|
371
|
+
> **When do you need the extension?** If you're automating modern SPAs with closed shadow DOM (e.g., Reddit), sites with strict Content Security Policy, or framework-heavy editors (Draft.js, ProseMirror, Slate).
|
|
372
|
+
|
|
373
|
+
### Installing the Extension
|
|
374
|
+
|
|
375
|
+
The extension requires a one-time build with Xcode (free, included with macOS):
|
|
376
|
+
|
|
377
|
+
**Prerequisites:** Xcode (install from App Store โ free)
|
|
378
|
+
|
|
379
|
+
```bash
|
|
380
|
+
# 1. Build the extension app
|
|
381
|
+
cd safari-mcp
|
|
382
|
+
xcodebuild -project "xcode/Safari MCP/Safari MCP.xcodeproj" \
|
|
383
|
+
-scheme "Safari MCP (macOS)" -configuration Release build
|
|
384
|
+
|
|
385
|
+
# 2. Find and open the built app
|
|
386
|
+
open ~/Library/Developer/Xcode/DerivedData/Safari_MCP-*/Build/Products/Release/Safari\ MCP.app
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
Then in Safari:
|
|
390
|
+
1. Safari โ Settings โ Advanced โ enable **Show features for web developers**
|
|
391
|
+
2. Safari โ Develop โ **Allow Unsigned Extensions** (required each Safari restart)
|
|
392
|
+
3. Safari โ Settings โ Extensions โ enable **Safari MCP Bridge**
|
|
393
|
+
|
|
394
|
+
The extension connects automatically to the MCP server on port `9224`.
|
|
395
|
+
|
|
396
|
+
> **Note:** "Allow Unsigned Extensions" resets every time Safari restarts. You'll need to re-enable it in the Develop menu after each restart. The extension itself stays installed.
|
|
397
|
+
|
|
398
|
+
**Toolbar icon status:**
|
|
399
|
+
- **ON** โ connected to MCP server
|
|
400
|
+
- **OFF** โ manually disabled via popup
|
|
401
|
+
- *(no badge)* โ server not running, will auto-reconnect
|
|
402
|
+
|
|
403
|
+
---
|
|
404
|
+
|
|
321
405
|
## macOS Permissions
|
|
322
406
|
|
|
323
407
|
Safari MCP needs these one-time permissions:
|
|
@@ -343,6 +427,20 @@ Safari MCP needs these one-time permissions:
|
|
|
343
427
|
|
|
344
428
|
---
|
|
345
429
|
|
|
430
|
+
## Works With
|
|
431
|
+
|
|
432
|
+
Safari MCP works with any MCP-compatible client:
|
|
433
|
+
|
|
434
|
+
| Client | Status |
|
|
435
|
+
|--------|--------|
|
|
436
|
+
| [Claude Code](https://claude.ai/claude-code) | โ
Tested daily |
|
|
437
|
+
| [Claude Desktop](https://claude.ai/download) | โ
Tested |
|
|
438
|
+
| [Cursor](https://cursor.sh) | โ
Tested |
|
|
439
|
+
| [Windsurf](https://codeium.com/windsurf) | โ
Compatible |
|
|
440
|
+
| [VS Code + Continue](https://continue.dev) | โ
Compatible |
|
|
441
|
+
|
|
442
|
+
---
|
|
443
|
+
|
|
346
444
|
## Contributing
|
|
347
445
|
|
|
348
446
|
PRs welcome! The codebase is two files:
|
|
@@ -351,6 +449,14 @@ PRs welcome! The codebase is two files:
|
|
|
351
449
|
|
|
352
450
|
---
|
|
353
451
|
|
|
452
|
+
## Star History
|
|
453
|
+
|
|
454
|
+
If Safari MCP saved you from Chrome overhead, consider giving it a โญ
|
|
455
|
+
|
|
456
|
+
[](https://star-history.com/#achiya-automation/safari-mcp&Date)
|
|
457
|
+
|
|
458
|
+
---
|
|
459
|
+
|
|
354
460
|
## License
|
|
355
461
|
|
|
356
|
-
MIT
|
|
462
|
+
MIT โ use it however you want.
|