Safari MCP Server
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.
README
Safari MCP Server
A Model Context Protocol (MCP) server that provides AI assistants with Safari browser automation and developer tools access. This server enables LLMs to interact with Safari, access console logs, monitor network activity, and perform browser automation tasks.
Features
- 🚀 Safari Browser Automation: Start, control, and manage Safari sessions
- 🔍 Developer Tools Access: Get console logs, network logs, and performance metrics
- 📸 Screenshots: Capture page screenshots for visual analysis
- 🕵️ Element Inspection: Inspect DOM elements and their properties
- ⚡ JavaScript Execution: Run custom JavaScript in the browser context
- 📊 Performance Monitoring: Access timing metrics and performance data
- 🔧 Multiple Sessions: Manage multiple Safari automation sessions
Prerequisites
System Requirements
- macOS only (Safari and SafariDriver are only available on macOS)
- Node.js 18+
- Safari 10+ (comes with built-in WebDriver support)
Safari Setup
Before using this MCP server, you need to enable Safari's automation features:
-
Enable Developer Menu:
- Open Safari → Preferences → Advanced
- Check "Show Develop menu in menu bar"
-
Enable Remote Automation:
- In Safari's menu bar: Develop → Allow Remote Automation
-
Authorize SafariDriver:
sudo safaridriver --enableEnter your admin password when prompted.
Installation
-
Clone or navigate to the project directory:
cd C:\Users\<USERNAME>\RiderProjects\AIPacketAnalyzer\safari-mcp-server -
Install dependencies:
npm install -
Build the project:
npm run build
Usage
Running the Server
npm start
The server will start and listen for MCP protocol messages on stdio.
Development Mode
npm run dev
Available Tools
Session Management
safari_start_session- Start a new Safari automation sessionsafari_close_session- Close a Safari sessionsafari_list_sessions- List all active sessions
Navigation & Page Info
safari_navigate- Navigate to a URLsafari_get_page_info- Get current page URL and title
Developer Tools Access
safari_get_console_logs- Get browser console logssafari_get_network_logs- Get network activity logssafari_get_performance_metrics- Get page performance metrics
Browser Interaction
safari_execute_script- Execute JavaScript in the browsersafari_take_screenshot- Capture page screenshotssafari_inspect_element- Inspect DOM elements
Example Usage with Claude Desktop
Add this configuration to your Claude Desktop config file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"safari-devtools": {
"command": "node",
"args": ["C:/Users/<USERNAME>/RiderProjects/AIPacketAnalyzer/safari-mcp-server/build/index.js"]
}
}
}
Example Commands
Once connected to an MCP client like Claude Desktop, you can use commands like:
Start a Safari session with ID "main" and navigate to Google:
- Start session: safari_start_session with sessionId "main"
- Navigate: safari_navigate to "https://www.google.com"
- Take screenshot: safari_take_screenshot
- Get console logs: safari_get_console_logs
Configuration Options
When starting a session, you can specify options:
{
"sessionId": "my-session",
"options": {
"enableInspection": true, // Enable Web Inspector
"enableProfiling": true, // Enable timeline profiling
"usesTechnologyPreview": false // Use Safari Technology Preview
}
}
Limitations
- Single Session Limit: Safari only allows one WebDriver session at a time
- macOS Only: This server only works on macOS systems
- Safari-Specific: Unlike Chrome DevTools Protocol, Safari has limited debugging API access
- Network Logs: Network logging depends on Safari's performance logs and may have limitations
Development
Project Structure
safari-mcp-server/
├── src/
│ ├── index.ts # Main entry point
│ ├── safari-mcp-server.ts # MCP server implementation
│ ├── safari-driver.ts # Safari WebDriver manager
│ └── types.ts # TypeScript type definitions
├── build/ # Compiled JavaScript
├── package.json
├── tsconfig.json
└── README.md
Building
npm run build
Watching for Changes
npm run watch
Cleaning Build
npm run clean
Troubleshooting
Common Issues
-
"Session not found" errors:
- Make sure you've started a session before using other commands
- Check that Safari didn't crash or close unexpectedly
-
"Remote Automation not enabled":
- Verify Safari's Developer menu is enabled
- Check that "Allow Remote Automation" is enabled in the Develop menu
-
Permission errors:
- Run
sudo safaridriver --enableand enter your password - Make sure Terminal has the necessary permissions
- Run
-
Safari not responding:
- Only one Safari automation session can be active at a time
- Close any existing automation sessions before starting new ones
Debug Mode
To see detailed logging, you can modify the server to include more verbose output or check Safari's Web Inspector while automation is running.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
MIT License - see LICENSE file for details.
Related Projects
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。