cli-anything-safari
Safari browser automation CLI on macOS via safari-mcp. Controls real Safari (native, keeps logins) by wrapping the safari-mcp MCP server. Every one of the 84 MCP tools is exposed 1:1 with schema-accurate arguments — guaranteed parity, no manual drift.
What this skill does
# cli-anything-safari A command-line interface for Safari browser automation on macOS. Wraps the [`safari-mcp`](https://github.com/achiya-automation/safari-mcp) Node.js MCP server in a Python Click CLI. **Feature parity is guaranteed.** Every Click command is generated automatically from `safari-mcp`'s tool schema (bundled as `resources/tools.json`). All 84 tools are reachable with the exact argument names and types the MCP server expects. ## When to use this CLI Each CLI invocation spawns a fresh subprocess, so there is per-call overhead. If your agent speaks MCP natively (Claude Code, Cursor, Cline, etc.), using `safari-mcp` directly over MCP stdio will be faster. **Use this CLI when:** - Your agent framework does **not** speak MCP (Codex CLI, GitHub Copilot CLI, custom scripts, older agent frameworks). - You need to **script browser automation from bash** — `cli-anything-safari --json tool snapshot | jq '...'`. - You run in **CI/CD** and want cron-able, subprocess-friendly output. - You're **debugging interactively** from Terminal. ## Installation ### Prerequisites 1. **macOS** — Safari MCP is macOS-only. 2. **Safari** — already installed on macOS. 3. **Node.js 18+** — `brew install node` or from https://nodejs.org/ 4. **Python 3.10+** 5. **Enable Apple Events for Safari**: Safari → Develop → Allow JavaScript from Apple Events ### Install the CLI ```bash cd safari/agent-harness pip install -e . ``` The first `tool` call will download the `safari-mcp` npm package (one-time, a few MB). ## Command Structure The CLI has 5 top-level commands: | Command | Purpose | |-----------|-------------------------------------------------------------------| | `tool` | Call any of safari-mcp's **84 tools** (dynamic, schema-driven) | | `tools` | Inspect the bundled tool registry (`list`, `describe`, `count`) | | `raw` | Escape hatch — call a tool by full name with raw JSON args | | `session` | In-memory session state (last URL, current tab) | | `repl` | Interactive REPL (default when no subcommand given) | ## Usage Examples ### Discover the tool surface ```bash # Count of tools (sanity check — must match safari-mcp's registered tools) cli-anything-safari tools count # → 84 # List every tool cli-anything-safari tools list cli-anything-safari tools list --filter click # filter by substring # Full schema for one tool (JSON or human format) cli-anything-safari tools describe safari_scroll cli-anything-safari --json tools describe safari_click ``` ### Call a tool (schema-driven) ```bash # Navigate cli-anything-safari tool navigate --url https://example.com # Take a snapshot (preferred over screenshot — structured text with ref IDs) cli-anything-safari --json tool snapshot # Click by ref (refs come from snapshot; they expire on the next snapshot!) cli-anything-safari tool click --ref 0_5 # Click by selector or visible text cli-anything-safari tool click --selector "#submit" cli-anything-safari tool click --text "Log in" # Fill a field cli-anything-safari tool fill --selector "#email" --value "[email protected]" # Scroll by direction/amount (NOT x/y — note the schema!) cli-anything-safari tool scroll --direction down --amount 500 # Drag one element onto another cli-anything-safari tool drag \ --source-selector ".card" \ --target-selector ".trash" # Screenshot — returns base64 JPEG in stdout. Decode with: cli-anything-safari --json tool screenshot --full-page \ | python3 -c "import sys,json,base64; \ d=json.load(sys.stdin); \ open('/tmp/shot.jpg','wb').write(base64.b64decode(d['data']))" # Save as PDF (this one writes to disk directly) cli-anything-safari tool save-pdf --path /tmp/page.pdf # Evaluate JavaScript (note: parameter is --script, not --code) cli-anything-safari tool evaluate --script "document.title" ``` ### Navigate and read in one round-trip ```bash cli-anything-safari --json tool navigate-and-read --url https://example.com ``` ### Form fill (bulk) `safari_fill_form` takes an **array** of `{selector, value}` objects. Pass it as a JSON string: ```bash cli-anything-safari tool fill-form --fields '[ {"selector": "#email", "value": "[email protected]"}, {"selector": "#password", "value": "hunter2"} ]' ``` Run `cli-anything-safari tools describe safari_fill_form` to see the exact schema, including any new fields safari-mcp adds upstream. ### Network monitoring ```bash cli-anything-safari tool start-network-capture cli-anything-safari tool navigate --url https://example.com cli-anything-safari --json tool network cli-anything-safari tool performance-metrics ``` ### Storage ```bash cli-anything-safari tool get-cookies cli-anything-safari tool set-cookie --name session --value abc123 --domain example.com cli-anything-safari tool local-storage --key theme # export-storage returns JSON to stdout — no --path arg. Pipe to a file: cli-anything-safari --json tool export-storage > /tmp/storage.json ``` ### Raw JSON escape hatch When you need to pass a complex nested object or want to drive the CLI from a pre-built JSON blob: ```bash cli-anything-safari raw safari_evaluate \ --json-args '{"code":"[...document.querySelectorAll(\"a\")].map(a => a.href)"}' ``` ### Interactive REPL ```bash cli-anything-safari ``` The REPL banner prints the absolute path to this SKILL.md so agents can self-discover capabilities. ## JSON Output All commands support `--json` as a global flag: ```bash cli-anything-safari --json tool snapshot cli-anything-safari --json tool list-tabs cli-anything-safari --json tools list ``` ## State Management The CLI maintains a small amount of in-memory state for REPL display only: - **`last_url`** — last URL the CLI navigated to (updated after every successful `tool navigate`, `tool navigate-and-read`, or `tool new-tab`) - **`current_tab_index`** — last known active tab index There is **no persistent session**, no undo/redo, no document model. Every CLI invocation starts with fresh state. Safari MCP itself is stateless per-call: each `tool` command spawns a fresh `npx safari-mcp` subprocess, performs the action, and exits. This is a deliberate design choice; see `HARNESS.md` and `TEST.md` for the reasoning behind the deviation from the standard undo/redo pattern. ## Output Formats All commands support dual output modes: - **Human-readable** (default): indented key-value text for `dict` results, bullet lists for arrays, plain text otherwise - **Machine-readable** (`--json` flag): structured JSON for agent consumption ```bash # Human output cli-anything-safari tool snapshot # JSON output for agents cli-anything-safari --json tool snapshot cli-anything-safari --json tools list cli-anything-safari --json tools describe safari_click ``` ## For AI Agents When using this CLI programmatically: 1. **Always use `--json` flag** for parseable output. 2. **Check return codes** — 0 for success, non-zero for errors (URL validation failures, MCP call failures, invalid JSON args). 3. **Parse stderr** for error messages; use stdout for data. 4. **File-handling tools have inconsistent path arg names** — always check `tools describe <name>` first: - `tool save-pdf --path /tmp/x.pdf` - `tool upload-file --selector ... --file-path /tmp/x.txt` (note: `--file-path`, not `--path`) - `tool export-storage` — no path arg; pipe JSON output to a file - `tool import-storage --path /tmp/x.json` - `tool screenshot` / `screenshot-element` — return base64 in the JSON response, no path arg (decode it yourself) 5. **Snapshot before click** — refs from `tool snapshot` expire on the next snapshot. Always snapshot → find ref → click in close succession. 6. **Discover tools via `tools list`** — the bundled registry is the source of truth for what's available. Do not hard-code tool names that may change upstream. 7. **Use `tools describe <name
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.