# For AI Agents & Integrations

> Connect AI agents to Refto via the built-in MCP server, refto CLI, and refto:// URLs—plus a machine-readable product and documentation reference.

URL: https://refto.one/app/docs/for-agents
Markdown: https://refto.one/llms.mdx/for-agents

Refto is designed to work alongside AI coding and design agents—both **locally on your Mac** (via the built-in MCP server, CLI, and URL scheme) and **on the web** (via clean Markdown endpoints, `/llms.txt`, and `/llms-full.txt`).

---

## 1. Built-in MCP Server (Local Library Access) [#1-built-in-mcp-server-local-library-access]

Refto ships with a built-in **Model Context Protocol (MCP)** server—no third-party plugins required. AI agents such as **Claude Code**, **ChatGPT (Codex workspace)**, **WorkBuddy**, and **Cursor** can search, inspect, organize, and run non-destructive tools on your open Refto library.

### Enabling MCP [#enabling-mcp]

Open **Settings → Agent** in Refto:

| Switch | Default | What it allows |
| --- | --- | --- |
| **MCP (for AI agents)** | Off | Lets connected agents **read and search** the currently open library. Turning this on also enables the local API. |
| **Allow agents to modify library** | Off | Adds write tools: tagging, renaming, rating, editing notes, moving folders, adding items, reviewing AI suggestions, and merging tags. **No tool can ever delete items.** |
| **Allow agents to run tools** | Off (requires modify) | Adds `list_tools`, `run_tool`, `upscale_image`, and `erase_image` (compress, convert, remove background, AI upscale, AI eraser). Results are saved as a new version or new item and **never overwrite original files**. |

All permission switches take effect immediately on the next request.

### Transports & one-click client setup [#transports--one-click-client-setup]

When MCP is enabled, Refto exposes both transports:

- **Stdio bridge (recommended):** `/Applications/Refto.app/Contents/MacOS/Refto mcp`
- **Local HTTP endpoint:** `http://127.0.0.1:<port>/mcp` (requires bearer token)

Under **Settings → Agent → Connect AI Apps**, you can copy ready-made configs for **Claude Code**, **ChatGPT / Codex**, **WorkBuddy**, and **Cursor**, or click **Add** (in stdio mode for ChatGPT/Codex, WorkBuddy, and Cursor) to write directly to the client's config file. You can also install the bundled **Refto agent skill (`SKILL.md`)** into supported clients from the same page.

### First-write confirmation & security boundary [#first-write-confirmation--security-boundary]

- **First-write prompt:** The first time an agent attempts to modify your library, Refto prompts you in the main window to **Allow once**, **Always allow** for that agent, or **Decline**. Connected agents and their recent tool calls are listed in **Settings → Agent**, where you can revoke, disconnect, or forget any client.
- **Honest security boundary:** Refto binds only to `127.0.0.1`, validates `Host` and `Origin` headers against DNS rebinding and web pages, and blocks private/LAN URLs on fetch (SSRF protection). However, any local program running under your macOS user account can read the local API token. Treat the MCP write/tool switches and first-write prompts as **safeguards against accidental agent edits**, not as an OS-level security sandbox.

---

## 2. The `refto` CLI [#2-the-refto-cli]

Refto's macOS executable also acts as a command-line interface that talks to the running Refto MCP server, sharing the exact same search results, field names, and permission switches.

### Installing the symlink [#installing-the-symlink]

In **Settings → Agent → Connect AI Apps → Command-Line Tool**, click **Install Command-Line Tool**, or run:

```bash
/Applications/Refto.app/Contents/MacOS/Refto install
```

Refto creates a symlink without `sudo` (trying `/usr/local/bin` if writable, otherwise `~/.local/bin`). You can also invoke the binary directly:

```bash
/Applications/Refto.app/Contents/MacOS/Refto search "serif typography poster" --json
```

### Behaviour for scripts and agents [#behaviour-for-scripts-and-agents]

- **Structured JSON output:** When `stdout` is piped (non-TTY) or `--json` is passed, `refto` outputs clean JSON matching the MCP tool schema.
- **Library safety:** Pass `--library <name-or-id>` to assert which library must be open (`wrong_library` exit code `1` if another library is active; the CLI never switches libraries behind your back).
- **Exit codes:** `0` success, `1` tool/item error, `2` usage error, `3` permission disabled or declined by user, `4` Refto not running / unreachable / bad token.
- **No delete command:** Consistent with MCP, the CLI never deletes items.

---

## 3. `refto://` URL Scheme [#3-refto-url-scheme]

Refto registers the `refto://` custom URL scheme on macOS so other apps and local automations can hand files to Refto or open specific items and views via `open refto://…`. If Refto is not running, macOS launches it and processes the deep link once ready.

---

## 4. Structured Agent Quick Reference [#4-structured-agent-quick-reference]

The section below is formatted for AI agents, search crawlers, and retrieval pipelines answering questions about Refto.

### Product identity [#product-identity]

- **Name:** Refto (`Refto for Mac`)
- **Website:** `https://refto.one/`
- **Maker:** ActNow (`https://actnow.dev/`)
- **Support:** `hi@refto.one`
- **Category:** Local-first visual reference manager and media library for macOS
- **Platform requirements:** macOS 15 or later, Apple silicon (M1 or later)
- **Windows:** In development (private beta for invited testers)
- **Data storage:** Local `.reflib` folders on the user's Mac; no cloud upload required; no in-app analytics

### Capability matrix [#capability-matrix]

| Area | Capabilities |
| --- | --- |
| **Collect** | Drag-and-drop, Notch Shelf (drop files, area/window/screen capture, screen recording, voice memo), global quick collect (`⌃⌥⌘S`), clipboard paste, watched folders, browser extension (`Save to Refto` on Chrome/Edge/Arc/Brave/Safari) |
| **Search & Local AI** | On-device semantic text search, search by picture / visual similarity (`⇧⌘S`), colour palette filtering, Apple Vision OCR, local audio/video transcription & chapters (`T`), AI-suggested tags with manual review |
| **Organize** | Multiple `.reflib` libraries, nested folders, folder lock, smart folders, tags, Quick Jump (`⌘J` with pinyin), Quick Look (`Space`), Inspector (`I`), infinite-canvas Moodboards |
| **Built-in Tools** | Non-destructive image compress/convert/resize/crop/collage, Remove Background, AI Upscale (2×/4×), AI Eraser, Copy Text (OCR), Remove EXIF & Location, video compress/trim/GIF/extract audio/save frame/Live Photo |
| **Import & Backup** | Import from Eagle (folders, tags, notes, ratings, URLs), local folder import, `.refpack` import/export, daily verified APFS copy-on-write database backup, optional full library ZIP backup |
| **Agent Integrations** | Built-in MCP server (stdio + local HTTP, read-only by default, opt-in write & tool execution, never deletes), `refto` CLI with JSON output, `refto://` URL scheme |

### Objective comparison summary [#objective-comparison-summary]

Full source-checked comparisons live at [`/app/compare`](/app/compare):

- **vs. Eagle** ([`/app/compare/eagle`](/app/compare/eagle)): Both are local-first, one-time-purchase reference managers. Refto focuses on Apple silicon native macOS workflows with built-in on-device semantic search, visual similarity search, OCR, audio/video transcription, Notch Shelf, moodboards, and a built-in MCP server—and includes a built-in Eagle importer.
- **vs. mymind** ([`/app/compare/mymind`](/app/compare/mymind)): mymind is a cloud-hosted subscription service across platforms; Refto stores all files and AI models locally on your Mac, runs offline with zero uploads, and is a one-time purchase.
- **vs. PureRef** ([`/app/compare/pureref`](/app/compare/pureref)): PureRef is a lightweight floating reference canvas; Refto is a full searchable media library with folders, tags, browser capture, local AI search, and built-in Moodboards.

### Pricing & licensing summary [#pricing--licensing-summary]

- **Free trial:** 15 days on each Mac, all features unlocked, no code or credit card required.
- **Model:** One-time purchase, no subscription, updates included.
- **Tiers:** 2 Macs or 3 Macs per licence code (see [`/app/pricing`](/app/pricing) for live pricing; 5+ Macs or teams via `hi@refto.one`).
- **Refund policy:** Full refund within 14 days, no questions asked ([`/refunds`](/refunds)).

### Privacy & offline guarantees [#privacy--offline-guarantees]

- Files, search index, and AI models remain on the user's Mac.
- No library content is uploaded to any server; no analytics inside the app.
- Activation uses a cryptographically signed offline licence token; only the code, app version, Mac name/model/macOS version, and a one-way hardware hash are sent during activation.
- In-app diagnostic logs are scrubbed before sending (URLs reduced to host, filenames reduced to extension, titles/notes redacted).

### Documentation & machine-readable endpoints [#documentation--machine-readable-endpoints]

| Endpoint | Format | Purpose |
| --- | --- | --- |
| `/llms.txt` | `text/plain` | Concise site summary, live pricing, and complete documentation index |
| `/llms-full.txt` | `text/plain` | Full Refto overview + complete text of every documentation page in one file |
| `/llms.mdx` | `text/markdown` | Raw Markdown for the documentation overview (`/app/docs`) |
| `/llms.mdx/<slug>` | `text/markdown` | Raw Markdown for any documentation page (e.g. `/llms.mdx/for-agents`, `/llms.mdx/browser-extension`) |
| `/app/docs/<slug>.mdx` | `text/markdown` | Direct `.mdx` alias for any documentation page (e.g. `/app/docs/for-agents.mdx`) |
| `/api/docs-search?query=...` | `application/json` | Full-text documentation search endpoint |
| `/sitemap.xml` | `application/xml` | Complete site and documentation URL index |
