This MCP Safari Server enables AI assistants like Claude to interact with Safari browser on macOS through a standardized protocol. It provides programmatic control for web automation, testing, and debugging by allowing navigation, JavaScript execution, and element interaction.
To install the MCP Safari Server:
cd mcp-safari-server
npm install
npm run build
Add the 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": {}
}
}
}
For development environments:
{
"mcpServers": {
"safari": {
"command": "npx",
"args": ["tsx", "/path/to/mcp-safari-server/src/index.ts"],
"env": {}
}
}
}
Once configured, Claude can use the following tools to control Safari:
Use the safari navigate tool to open https://example.com
Use the safari get_page_info tool to see the current URL and title
Use the safari refresh_page tool
Use the safari go_back tool to go to the previous page
Use the safari execute_script tool to run: document.querySelector('h1').textContent
Use the safari get_console_logs tool to see any console messages
Use the safari click_element tool with selector "#submit-button"
Use the safari click_element tool with selector "a.nav-link" and waitForNavigation true
Use the safari type_text tool with selector "#email" and text "[email protected]"
Use the safari type_text tool with selector "#password" and text "mypassword" and clearFirst false
Use the safari scroll_to tool with selector "#footer"
Use the safari scroll_to tool with y 500 and behavior "smooth"
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 2
Use the safari get_element_text tool with selector "h1"
Use the safari get_element_text tool with selector ".error-message"
Use the safari wait_for_element tool with selector "#loading-complete"
Use the safari wait_for_element tool with selector ".modal" and timeout 5000
Use the safari take_screenshot tool to capture the current page
Use the safari start_error_monitoring tool
Options:
interval
: Check interval in milliseconds (default: 2000)autoSendToClaude
: Automatically send errors to Claude Code (default: true)Use the safari stop_error_monitoring tool
The Safari MCP server can automatically monitor JavaScript errors and send them to Claude Code for immediate fixing:
navigate
toolstart_error_monitoring
stop_error_monitoring
when doneTo add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "safari" '{"command":"node","args":["/path/to/mcp-safari-server/dist/index.js"],"env":[]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"safari": {
"command": "node",
"args": [
"/path/to/mcp-safari-server/dist/index.js"
],
"env": []
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"safari": {
"command": "node",
"args": [
"/path/to/mcp-safari-server/dist/index.js"
],
"env": []
}
}
}
3. Restart Claude Desktop for the changes to take effect