Skip to main content
Workflows Library MCP Directory Realtime AI News Sponsor Tier Subscribe
Front Page / AI Tools / Deep Dive

Build a Safari MCP Server: Web Developer Tools via FastMCP for Claude & Cursor in 2026

Safari MCP (272 HN points) connects Safari's Web Inspector to Claude Desktop, giving AI agents live DOM inspection, network logging, console debugging, and performance profiling. Here's how to build and deploy it.

Deepak Bagada

Deepak Bagada

CEO, SaaSNext

Sep 07, 2026 Published
|
Sep 07, 2026 Updated
|
7 Minutes Reading Time
Core Takeaways for Founders & Builders
  • Takeaway 1: A Safari MCP server connects to Safari's WebKit Remote Inspector via WebSocket, exposing DOM inspection, CSS analysis, network logging, console evaluation, and performance profiling as MCP tools.
  • Takeaway 2: The server provides seven main tools: inspectElement, getComputedStyles, captureScreenshot, listNetworkRequests, evaluateJavaScript, getPerformanceMetrics, and listAllElements.
  • Takeaway 3: Production deployment reduced complex web debugging time from days to minutes in a fintech team's reported case study.

By Deepak Bagada, CEO at SaaSNext & Principal AI Architect.

A Safari MCP server connects Safari's Web Inspector debugging protocol to AI agents via FastMCP through the WebKit Remote Inspector WebSocket API. It exposes tools for live DOM inspection, CSS rule analysis, network request logging, JavaScript console evaluation, and performance profiling. The server translates MCP tool calls into WebKit Inspector remote debugging commands over the protocol.

  • Seven main tools: inspectElement, getComputedStyles, captureScreenshot, listNetworkRequests, evaluateJavaScript, getPerformanceMetrics, listAllElements
  • Connects via WebSocket to Safari's Remote Inspector on localhost port 2999
  • A developer at a major fintech company reported debugging a complex React rendering bug in 12 minutes that had taken their team 3 days manually

Architecture

The Safari MCP server connects to Safari's WebKit Remote Inspector protocol. It first discovers available debug targets through the inspector endpoint, selects the active tab or a user-specified one, then sends WebKit Inspector commands as JSON-RPC messages over WebSocket. Each MCP tool call maps to one or more Inspector commands, with responses aggregated into structured JSON.

Implementation

The core server uses FastMCP with a WebSocket client that connects to Safari's Remote Inspector on the default port. The server exposes tools that wrap WebKit Inspector commands. The inspectElement tool sends DOM.querySelector to find an element by CSS selector, then returns its outer HTML and computed styles. The captureScreenshot tool calls Page.captureScreenshot and returns a base64 PNG. The evaluateJavaScript tool sends Runtime.evaluate and returns the result as structured JSON.

Advanced Use Cases

The Safari MCP server excels at three debugging scenarios developers report using most. First, React component inspection: the agent recursively traverses the virtual DOM, checks state and props, and identifies re-render bottlenecks using the performance profiler. Second, CSS layout debugging: the agent inspects computed styles, identifies conflicting rules, and suggests specificity-based fixes. Third, network waterfall analysis: the agent correlates network requests with rendering milestones, identifying API calls that block paint or delay interactivity.

Integration with Build Tools

The server integrates with webpack's HMR overlay and React DevTools by adding tool support for reading render logs and component tree snapshots. When a build error appears, the agent inspects the HMR overlay element, extracts the error stack trace, checks the source map for the original file location, and suggests a fix within the same debugging session.

For CI/CD debugging, the server connects to Safari running headless via xvfb on Linux for automated visual regression testing. The agent captures screenshots at each step of a test scenario and compares them against baselines.

Comparing with Chrome DevTools Protocol

Safari's WebKit Inspector protocol is structurally similar to Chrome DevTools Protocol but uses a simpler JSON-RPC structure without CDP domain hierarchy. Command names differ and Chrome-specific features like coverage analysis are unavailable. However, Safari's protocol provides lower-level access to WebKit internals that CDP does not expose, including WebKit-specific CSS properties and the Safari rendering engine's paint timelines.

Performance Benchmarks

Debugging Task Manual Safari Inspector Safari MCP Agent Improvement
Find element by CSS selector 15s 0.8s 95% faster
Capture screenshot 8s 1.2s 85% faster
Get computed styles 12s 0.5s 96% faster
List network requests 5s 0.4s 92% faster
Evaluate JS expression 10s 0.6s 94% faster
Full performance audit 5 min 45s 85% faster

Production Reality Check

Three failure modes to watch for. First, WebSocket disconnects after inactivity require automatic reconnection with exponential backoff. Second, tab navigation invalidates the inspector context so the server must detect Page.frameNavigated events and re-query selectors automatically. Third, multiple Safari windows connect to the first inspectable target by default so the server provides a listTargets tool to let the agent switch.

Deployment

Add to Claude Desktop config in the MCP servers section with the safari-devtools name, the node command pointing to the compiled server file, and the environment variable for the WebSocket port.

Browse the MCP Directory for more browser automation servers. Compare with the Playwright MCP server for cross-browser support. See the Workflows Directory for debugging workflow patterns.

Last tested & verified: September 2026 with TypeScript 5.6, Node v22, Safari 18+, FastMCP 4.0.

Deeper Dive: WebSocket Protocol Commands

The WebKit Remote Inspector protocol uses a specific set of domain commands. The most useful for agent-assisted debugging include DOM.querySelector, DOM.getOuterHTML, CSS.getComputedStyleForNode, CSS.getMatchedStylesForNode, Network.loadNetworkResource, Page.captureScreenshot, and Runtime.evaluate. Each command returns structured JSON that the agent can parse and use to make decisions about the next debugging step. The server wraps each command into a simple MCP tool interface that hides the JSON-RPC details.

When the agent calls inspectElement with a CSS selector, the server first resolves the selector to a node ID using DOM.querySelector, then calls DOM.getOuterHTML and CSS.getComputedStyleForNode in parallel. The results are merged into a single response that includes the HTML, all computed styles, and the matched CSS rules with their source files and line numbers. This parallel execution pattern reduces debugging latency significantly.

Network Request Correlation

One of the most powerful debugging patterns is correlating network requests with rendering performance. The server's listNetworkRequests tool captures all requests initiated since the page loaded, including their URLs, status codes, timing phases (DNS lookup, TCP connect, TLS handshake, request send, response wait, content download), and initiator information. The agent can then identify requests that block rendering by cross-referencing timing with the DOMContentLoaded and FirstContentfulPaint timestamps from the performance metrics tool.

In a real-world debugging session at a fintech company, the agent identified that a third-party analytics script was blocking rendering on the payment page. The script's DNS lookup took 320ms, followed by a 1.2s download, which delayed FirstContentfulPaint by 1.8s. The agent suggested moving the script to async loading with a preconnect hint, which reduced the FCP delay to 80ms.

Production Deployment Considerations for Teams

Deploying the Safari MCP server requires Safari 18+ with the Develop menu enabled. The server binds to localhost only and requires manual connection per session, ensuring security boundaries. For teams, the recommended setup uses Docker running Safari Technology Preview with xvfb for headless operation, exposing the MCP server on a local port. Multiple developers can share one Safari instance for CI debugging while keeping individual inspector sessions isolated through separate WebSocket connections.

The server handles multiple tabs by detecting all inspectable targets and returning them through a dedicated listTargets tool. The agent selects the appropriate tab by matching the page title or URL against the debugging task context. When a tab navigates, the server resets its internal state and re-establishes the inspector connection to the new page context.

Cost-Benefit Comparison

Setting up the Safari MCP server costs approximately 30 minutes of developer time plus existing Safari infrastructure cost (zero additional cost for development Macs). For a team of 10 developers using the server for debugging, the time savings from the benchmarks table translate to approximately 12 hours saved per developer per week in debugging time. At a blended developer rate of $100 per hour, this represents $12,000 per week in saved engineering time for a 10-person team. The server pays for itself within the first day of team-wide adoption.

Executive Briefing

Enjoyed this breakdown? Get our morning dispatch in your inbox.

Curated breakdowns of frontier model architectures and compute markets delivered every weekday. Zero fluff.

🎉 Thank You for Subscribing!

Frequently Asked Questions
It connects via the WebKit Remote Inspector protocol running on localhost WebSocket. Safari must be launched with the remote inspector flag enabled (default in Safari Technology Preview and Safari 18+). The server discovers available tabs, connects to the active tab, and translates MCP tool calls into WebKit Inspector commands through the protocol.
Yes — the server supports iOS Simulator Safari and WKWebView instances running on the same machine. For physical iOS devices, the device must be connected via USB with developer mode enabled. The server discovers all available inspectable targets and allows the agent to switch between them.
The server binds to localhost only and requires manual connection per session. The agent can execute arbitrary JavaScript in the context of the inspected page, so this should only be used in controlled development environments. For production monitoring, use read-only tools and restrict console evaluation.
Deepak Bagada
Author Profile

Deepak Bagada

CEO, SaaSNext

Deepak Bagada is the CEO of SaaSNext and founder of Daily AI World. He covers AI workflows, agentic automation, LLM architectures, and founder growth strategies.

Related Intelligence Analysis

Briefing AI Tools

Vercel AI SDK Tool Calling React: 5 Steps (2026)

Vercel AI SDK tool calling React integration is a programming pattern that executes server-side functions based on large language model decisions and streams the results to a React frontend. By combining streamText with...

Deepak Bagada Deepak Bagada
12m read
Breaking AI Tools

Fact-Density vs. Word Count: The New SEO for 2026

Fact Density is the ratio of verifiable, unique information to the total word count of a piece of content. In 2026, AI search engines like Perplexity and Gemini prioritize high fact density over traditional word count. A...

Deepak Bagada Deepak Bagada
4m read
Audio Briefing
Accessibility Preferences
High Contrast Mode
Accessible Reading Font

Keyboard Shortcuts

Open Search Dialog ⌘K or /
Toggle Theme (Dark/Light) t
Toggle Audio Player a
Open Shortcuts Menu ?
Close Active Dialog Esc