MCP Safari Server
Allows execution of JavaScript code within the current page context in Safari, as well as monitoring JavaScript errors, console logs, and interacting with DOM elements through JavaScript.
Enables browser automation specifically on macOS systems through AppleScript commands to control Safari browser.
Provides programmatic control of Safari browser on macOS, enabling navigation, JavaScript execution, element interaction, page monitoring, and screenshot capture for web automation and testing.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Safari Server take a screenshot of the current page"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Safari Server
A Model Context Protocol (MCP) server that provides programmatic control of Safari browser on macOS. Perfect for web automation, testing, and debugging with AI assistants like Claude.
Overview
The Safari MCP Server enables AI assistants to interact with Safari browser through a standardized protocol. It provides tools for navigation, element interaction, JavaScript execution, and page monitoring, making it ideal for:
๐ค AI-assisted web development and debugging
๐งช Automated testing and QA
๐ Web scraping and data extraction
๐ Real-time error monitoring
๐ธ Visual regression testing
Related MCP server: browser-use MCP server
Features
Navigate: Open URLs in Safari
Execute JavaScript: Run JS code in the current page context
Get Page Info: Retrieve current URL and page title
Take Screenshots: Capture the current Safari window
Console Logs: Capture and retrieve console.log, console.error, and console.warn messages
Page Navigation: Refresh, go back, or go forward in browser history
Automatic Error Monitoring: Monitor JavaScript errors and send them to Claude Code for immediate fixing
Click Elements: Click on page elements using CSS selectors
Type Text: Fill in forms and input fields
Scroll: Scroll to specific elements or positions
Select Options: Choose options from dropdown menus
Get Element Text: Extract text content from page elements
Wait for Elements: Wait for elements to appear before interacting
Installation
Install dependencies:
cd mcp-safari-server
npm installBuild the server:
npm run buildConfiguration
Add this server to your Claude configuration file (.mcp.json or claude-code-config.json):
{
"mcpServers": {
"safari": {
"command": "node",
"args": ["/path/to/mcp-safari-server/dist/index.js"],
"env": {}
}
}
}Or for development:
{
"mcpServers": {
"safari": {
"command": "npx",
"args": ["tsx", "/path/to/mcp-safari-server/src/index.ts"],
"env": {}
}
}
}Usage
Once configured, Claude can use the following tools:
navigate
Navigate Safari to a URL:
Use the safari navigate tool to open https://example.comexecute_script
Execute JavaScript in the current page:
Use the safari execute_script tool to run: document.querySelector('h1').textContentget_page_info
Get information about the current page:
Use the safari get_page_info tool to see the current URL and titletake_screenshot
Take a screenshot of the current Safari window:
Use the safari take_screenshot tool to capture the current pageget_console_logs
Retrieve console logs from the page:
Use the safari get_console_logs tool to see any console messagesrefresh_page
Refresh the current page:
Use the safari refresh_page toolgo_back / go_forward
Navigate through browser history:
Use the safari go_back tool to go to the previous pagestart_error_monitoring
Start monitoring JavaScript errors and automatically send them to Claude Code:
Use the safari start_error_monitoring toolOptions:
interval: Check interval in milliseconds (default: 2000)autoSendToClaude: Automatically send errors to Claude Code (default: true)
stop_error_monitoring
Stop error monitoring:
Use the safari stop_error_monitoring toolclick_element
Click on an element in the page:
Use the safari click_element tool with selector "#submit-button"
Use the safari click_element tool with selector "a.nav-link" and waitForNavigation truetype_text
Type text into an input field:
Use the safari type_text tool with selector "#email" and text "user@example.com"
Use the safari type_text tool with selector "#password" and text "mypassword" and clearFirst falsescroll_to
Scroll to an element or position:
Use the safari scroll_to tool with selector "#footer"
Use the safari scroll_to tool with y 500 and behavior "smooth"select_option
Select an option from a dropdown:
Use the safari select_option tool with selector "#country" and value "US"
Use the safari select_option tool with selector "#size" and text "Large"
Use the safari select_option tool with selector "#priority" and index 2get_element_text
Get the text content of an element:
Use the safari get_element_text tool with selector "h1"
Use the safari get_element_text tool with selector ".error-message"wait_for_element
Wait for an element to appear:
Use the safari wait_for_element tool with selector "#loading-complete"
Use the safari wait_for_element tool with selector ".modal" and timeout 5000
## Error Monitoring Feature
The Safari MCP server can automatically monitor JavaScript errors in your web application and send them to Claude Code for immediate fixing. This creates a powerful development workflow where:
1. You develop your web app
2. Safari MCP monitors for JavaScript errors
3. When errors occur, they're automatically sent to Claude Code
4. Claude can analyze the errors and suggest or implement fixes
### How Error Monitoring Works
When you start error monitoring, the server:
1. Injects JavaScript into the Safari page to capture:
- Unhandled errors (window.onerror)
- Unhandled promise rejections
- Console.error calls
2. Checks for new errors at the specified interval (default: every 2 seconds)
3. If errors are found and Claude Code is active, sends a notification containing:
- Error type and message
- File location and line/column numbers
- Stack traces
- Current page URL
- Timestamp
4. Claude Code receives the notification and can prompt you to fix the errors
### Example Workflow
1. Start your development server
2. Navigate to your app in Safari using the `navigate` tool
3. Start error monitoring with `start_error_monitoring`
4. As you interact with your app, any JavaScript errors will be captured
5. Claude Code will receive notifications about errors and can help fix them
6. Stop monitoring with `stop_error_monitoring` when done
## Requirements
- macOS (uses AppleScript to control Safari)
- Safari browser
- Node.js 16+
## Security Note
This server executes AppleScript commands to control Safari. Only use it in trusted environments and be careful with the JavaScript code you execute.
## Troubleshooting
1. **Safari automation permission**: You may need to grant Terminal/your IDE permission to control Safari in System Preferences > Security & Privacy > Privacy > Automation.
2. **Script execution errors**: Check that Safari is installed and not blocked by any security software.
3. **Console log capture**: The console log capture feature injects a script into the page. Some pages with strict Content Security Policies might block this.Available Tools
16 toolsclick_elementC
Click on an element in the page using CSS selector
Inputs: selector (required), waitForNavigation.
execute_scriptB
Execute JavaScript in the current Safari page
Inputs: script (required).
get_console_logsB
Get console logs from the current page
Inputs: no named parameters.
get_element_textB
Get the text content of an element
Inputs: selector (required).
get_page_infoA
Get information about the current page (URL, title, etc.)
Inputs: no named parameters.
go_backA
Navigate back in Safari history
Inputs: no named parameters.
go_forwardA
Navigate forward in Safari history
Inputs: no named parameters.
refresh_pageA
Refresh the current Safari page
Inputs: no named parameters.
scroll_toC
Scroll to a specific element or position
Inputs: behavior, selector, x, y.
select_optionC
Select an option from a dropdown
Inputs: selector (required), index, text, value.
start_error_monitoringC
Start monitoring Safari for JavaScript errors and optionally send them to Claude Code
Inputs: autoSendToClaude, interval.
stop_error_monitoringB
Stop monitoring Safari for JavaScript errors
Inputs: no named parameters.
take_screenshotB
Take a screenshot of the current Safari window
Inputs: filename.
type_textB
Type text into an input element
Inputs: selector (required), text (required), clearFirst.
wait_for_elementC
Wait for an element to appear on the page
Inputs: selector (required), timeout, visible.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
TDQS
Scored across 16 tools
Each tool has a clearly distinct purpose with no overlap: navigation tools (navigate, go_back, go_forward, refresh_page), element interaction tools (click_element, get_element_text, select_option, type_text, wait_for_element, scroll_to), page information tools (get_page_info, get_console_logs, take_screenshot), script execution (execute_script), and error monitoring (start_error_monitoring, stop_error_monitoring). The descriptions make it easy to differentiate between similar-sounding tools like get_element_text and get_page_info.
All tool names follow a consistent verb_noun pattern using snake_case (e.g., click_element, execute_script, get_console_logs). The naming is predictable and readable throughout, with no deviations in style or convention. This consistency helps agents easily parse and understand the toolset.
With 16 tools, the count is well-scoped for a Safari automation server, covering essential browser interactions without bloat. Each tool serves a specific, useful function in web automation (e.g., navigation, element manipulation, debugging), and there are no redundant or trivial tools. This aligns with typical automation toolkits that require a moderate number of focused operations.
The toolset provides comprehensive coverage for Safari automation, including navigation (navigate, go_back, go_forward, refresh_page), element interaction (click, type, select, wait, scroll), page inspection (info, logs, screenshot), script execution, and error monitoring. There are no obvious gaps; agents can perform full web automation workflows from loading pages to interacting with elements and debugging, with clear lifecycle coverage (e.g., start/stop monitoring).
Related MCP Connectors
Web data extraction and browser workflows for AI assistants.
AI-powered browser automation โ navigate, click, fill forms, and extract data from any website.
Cloud browser, web extraction, screenshots, and remote CDP tools for AI agents.
Control a real browser from AI agents: navigate, click, type, screenshot, read the page.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA web browser automation server that allows AI assistants to control Chrome with persistent state management, enabling complex browsing tasks through asynchronous browser operations.2-
- AlicenseDqualityDmaintenanceAI-driven browser automation server that implements the Model Context Protocol to enable natural language control of web browsers for tasks like navigation, form filling, and visual interaction.12MIT
- AlicenseNot gradedqualityNot gradedmaintenanceA Model Control Protocol server that enables AI assistants to control a browser through tools for web automation tasks like navigation, typing, clicking, and taking screenshots.Apache 2.0
- AlicenseNot gradedqualityNot gradedmaintenanceEnables AI assistants to control a browser through a set of tools, allowing them to perform web automation tasks like navigation, typing, clicking, and taking screenshots.Apache 2.0