---
title: Connecting an AI agent to Safari
framework: Safari Developer Features
role: article
role_heading: Article
path: safari-developer-tools/connecting-an-ai-agent-to-safari
---

# Connecting an AI agent to Safari

Inspect, test, and debug your website with an AI agent connected to the Safari MCP server.

## Overview

Overview Safari 27 and later includes a Model Context Protocol (MCP) server, which lets you connect an AI agent to a set of tools that inspect and interact with your pages. These tools can open tabs, load pages, read the Document Object Model (DOM), capture screenshots, monitor console and network activity, and simulate clicks, taps, and keystrokes in an active webpage. After you connect your AI agent to the Safari MCP server, you can ask the agent to perform common development tasks such as: Reviewing how your page behaves in Safari for compatibility testing Analyzing your page’s performance Confirming your page’s accessibility support Testing your page’s interactions Enable web developer features and remote automation Before you connect your AI agent, enable web developer features and remote automation in Safari. First, follow the steps in Enabling features for web developers to enable the Develop menu and Developer settings tab. Then, enable remote automation so that your AI agent can connect to the MCP server: Choose Safari > Settings. Select the Developer tab. Check the “Allow remote automation and external agents” box. Configure an AI agent to use the Safari MCP server After you enable remote automation and external agent access in Safari, you can configure your AI agent to connect to the Safari MCP server. In Claude Code, use the command claude mcp add to add the Safari MCP server configuration. Provide a name for the server, such as “safari-mcp”, and provide the path to the safaridriver binary inside the Safari application bundle with the --mcp flag:      claude mcp add safari-mcp -- "/usr/bin/safaridriver" --mcp

In Codex, use the command codex mcp add to add the Safari MCP server configuration. Provide a name for the server, such as “safari-mcp”, and provide the path to the safaridriver binary inside the Safari application bundle with the --mcp flag:      codex mcp add safari-mcp -- "/usr/bin/safaridriver" --mcp

If your agent uses an mcp.json or config.json file, add the Safari MCP server configuration with an entry that names the command and its arguments directly, as in the following example:      {   "mcpServers": {     "safari-mcp": {       "command": "/usr/bin/safaridriver",       "args": ["--mcp"]     }   } }      Navigate to a webpage with a prompt Start by writing a prompt that specifies a URL and the action you want to perform; for example, “Open my site at example.com in Safari and tell me if it loaded correctly.” The agent uses the Safari MCP server to open a new window in Safari and load the site you request in that window, and then uses the MCP server’s tools to see if the webpage loaded correctly. Safari displays a banner below the top toolbar that indicates your AI agent controls the window. After the webpage opens in the window and the agent verifies it loaded correctly, the agent responds with a message similar to this example:      I opened example.com in Safari. The page loaded successfully with a 200 response and the title "Example Domain." No console errors were reported.

If you request actions in your first prompt before navigating to a webpage and opening the window that the agent controls, such as listing open tabs or opening a new tab, the Safari MCP server may return an error. Interact with webpages in Safari using the MCP server tools As you’re building and maintaining your webpages, you can ask your AI agent to interact with, test, and analyze your webpages in Safari. The MCP server provides tools that let your agent perform these types of actions: Open a new tab, list open tabs, switch between tabs, and close a tab. Navigate to a URL, wait for a webpage to finish loading, and provide basic page information such as title and load status. Inspect rendered page content, take a screenshot, list network requests from the page, and review console messages. Set a viewport size, switch to the light or dark appearance, and view the page with reduced motion. Test clicks, typing, scrolling, hovering, and pressing keys. Run JavaScript in the page’s context. Accept or dismiss browser dialogs. The following table lists the tools that the Safari MCP server provides:  |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |   |

## See Also

### Tools

- [Develop menu](safari-developer-tools/develop-menu.md)
- [Web Inspector](safari-developer-tools/web-inspector.md)
- [Responsive Design Mode](safari-developer-tools/responsive-design-mode.md)
- [Inspect Apps and Devices](safari-developer-tools/inspect-apps-and-devices.md)
- [WebDriver](safari-developer-tools/webdriver.md)
