safari

Working notes about automating Safari, Apple's web browser, especially while testing the MCP Inspector interface. They record experiments, problems, and lessons learned.

In plain words
What is it for?
Use them when investigating Safari windows, tabs, and MCP Inspector connections, or when turning trial-and-error findings into reliable automation rules.
Why use it?
They preserve the details behind a working browser-automation process so future runs can avoid repeating failed approaches.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/mantisware/peepit/safari
Clone the repo
git clone --depth 1 https://github.com/MantisWare/peepit

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 4,107 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 100% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.04107
Opus 5 $0.00000 $0.02054
Sonnet 5 $0.00000 $0.00821
Haiku 4.5 $0.00000 $0.00411

Measured yesterday against content hash e8852ec59d92, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

safari scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

100% identical to safari — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

.cursor/rules/safari.mdc · 217 lines

How it starts

The opening of the file, as written. The whole thing — 217 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Meta Note

This file, safari.mdc, serves as a repository for detailed working notes, observations, and learnings acquired during the process of automating Safari interactions, particularly for the MCP Inspector UI. It's intended to capture the nuances of trial-and-error, debugging steps, and insights into what worked, what didn't, and why.

This contrasts with mcp-inspector.mdc, which is designed to be the concise, polished, and operational ruleset for future automated runs once a specific automation flow (like connecting to the MCP Inspector) has been stabilized and proven reliable. mcp-inspector.mdc should contain the 'final' working scripts and minimal necessary commentary, while safari.mdc is the space for the extended antechamber of discovery.


Key Learnings and Observations from Safari Automation (MCP Inspector)

1. Managing Safari Windows and Tabs for the Inspector
  • Objective: Reliably direct Safari to the MCP Inspector URL (http://127.0.0.1:6274) in a predictable way, preferably using a single, consistent browser window and tab to avoid disrupting the user's workspace or losing context.
  • **Initial Challenges & Evolution:
    • Simply using make new document with properties {URL:"..."} could lead to multiple windows/tabs if not managed.
    • Attempts to close all existing Inspector tabs first (repeat with w in windows... close t...) were functional but could be overly aggressive if the user had other work in Safari.
    • Identifying and reusing an existing specific tab for the Inspector requires careful targeting (e.g., first tab whose URL starts with "..."). If this tab was from a previous, unconfigured session, just switching to it wasn't enough; it needed to be reloaded/reset.
  • **Refined & Recommended Approach (as implemented in mcp-inspector.mdc):
    tell application "Safari"
      activate
      delay 0.2 -- Allow Safari to become the frontmost application
      if (count of windows) is 0 then
        -- No Safari windows are open, so create a new one.
        make new document with properties {URL:"http://127.0.0.1:6274"}
      else
        -- Safari has windows open; use the frontmost one.
        tell front window
          set inspectorTab to missing value
          try
            -- Check if a tab for the Inspector is already open in this window.
            set inspectorTab to (first tab whose URL starts with "http://127.0.0.1:6274")
          end try
          
          if inspectorTab is not missing value then
            -- An Inspector tab exists: set its URL again (to refresh/reset) and make it active.
            set URL of inspectorTab to "http://127.0.0.1:6274"
            set current tab to inspectorTab
          else
            -- No specific Inspector tab found: set the URL of the *current active tab*.
            set URL of current tab to "http://127.0.0.1:6274"
          end if
        end tell
      end if
      delay 1 -- Pause to allow the page to begin loading.
    end tell
    
    This logic aims to use the existing front window and either reuse/refresh an Inspector tab or repurpose the current active tab, falling back to creating a new window only if Safari isn't open.

Read the full file on GitHub · 217 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 217 lines · 0 tokens per session scan A e8852ec59d92

Subscribe to this mod's changes

safari is a cursor rule published in the GitHub repository MantisWare/peepit (2 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 4,107 tokens. A static security scan graded it A with 0 findings. It is 100% identical to safari, differing in 0 lines, and is treated as a copy.