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.
- π 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
- macOS only (Safari and SafariDriver are only available on macOS)
- Node.js 18+
- Safari 10+ (comes with built-in WebDriver support)
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 --enable
Enter your admin password when prompted.
-
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
npm startThe server will start and listen for MCP protocol messages on stdio.
npm run devsafari_start_session- Start a new Safari automation sessionsafari_close_session- Close a Safari sessionsafari_list_sessions- List all active sessions
safari_navigate- Navigate to a URLsafari_get_page_info- Get current page URL and title
safari_get_console_logs- Get browser console logssafari_get_network_logs- Get network activity logssafari_get_performance_metrics- Get page performance metrics
safari_execute_script- Execute JavaScript in the browsersafari_take_screenshot- Capture page screenshotssafari_inspect_element- Inspect DOM elements
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"]
}
}
}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
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
}
}- 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
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
npm run buildnpm run watchnpm run clean-
"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
To see detailed logging, you can modify the server to include more verbose output or check Safari's Web Inspector while automation is running.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details.