# Agents

Ferry's MCP server lets an AI assistant open links by intent and explain where a link went. It can suggest rules, but it can never change your routing on its own.

## Connect an agent

Ferry speaks the [Model Context Protocol](https://modelcontextprotocol.io) over stdio. Add this to your agent's MCP configuration:

```json
{"mcpServers":{"ferry":{"command":"ferry","args":["mcp"]}}}
```

**Settings › Agents** has a button that copies it.

Then ask in plain language: *"Open the release notes in my work profile."* or *"Why did that Linear link open in Chrome?"*

## What an agent can do

| Tool | Does | Changes anything? |
| --- | --- | --- |
| `open_url` | Opens a link, optionally in a named intent | Opens a link |
| `explain_route` | Shows where a link would go | No |
| `clean_url` | Returns the cleaned link and what was removed | No |
| `list_intents` | Lists intents and whether each can open here | No |
| `list_browsers` | Lists browsers and profiles | No |
| `list_rules` | Lists rules, including broken ones and why | No |
| `preview_rule` | Tries a rule against example links | No |
| `propose_rule` | Asks you to add a rule | Queues a proposal |
| `list_proposals` | Shows whether earlier proposals were approved | No |
| `check_config` | Reports problems in `ferry.toml` | No |
| `get_history` | Reads recent routes | No. Off by default. |

Route results come back as a [trace](/traces), so the agent can quote the rule that fired rather than guess.

## What an agent cannot do

- **Change your rules or intents.** No tool writes your config.
- **Open anything but web links.** `open_url` accepts `http` and `https` only. A `javascript:` or `file:` link is refused.
- **Flood you with tabs.** `open_url` is limited to 10 calls every 10 seconds.
- **Read your history**, unless you turn that on.
- **Get around the checks you get.** A browser or profile an agent names is validated exactly like one you enter in Settings.

## Proposals

When an agent thinks a rule would help, it calls `propose_rule`. Nothing changes yet. Ferry notifies you, and the proposal waits in **Settings › Agents** and in the menu bar.

The review sheet shows:

- which agent asked
- the rule, exactly as it would be written to your config
- the agent's reason
- a preview: one example link, and the trace it would produce

**Approve** appends the rule, with a comment saying which agent proposed it. **Reject** leaves your config untouched. Proposals you don't act on expire after 7 days.

An agent can check its work first. `preview_rule` runs a rule against example links and reports, for each, the trace before and after, and whether an earlier rule would shadow it:

```
As rule 3, this would change 1 of 2 example links. Nothing was saved.
1. https://github.com/acme/app
   now:  MCP: Claude → no rule matched (0 of 2) → ask
   then: MCP: Claude → rule 3 "GitHub" → @work → Chrome · Work
2. https://linear.app/acme
   No change: rule 2 "Linear" already catches this link.
```

Ferry rejects a proposal up front if the rule is invalid, or if it duplicates a rule you already have or one already waiting.

## The agent sandbox

Pages an agent opens don't have to land in the browser profile where you're signed in to everything.

Create an intent named `agent` and point it somewhere clean, such as a browser profile with no logins:

```toml
[intents.agent]
label = "Agent"
macos = { browser = "com.google.Chrome", profile = "Profile 3" }
```

From then on, a link an agent opens **without naming a destination** goes to `@agent` instead of through your rules:

<pre class="trace">MCP: Claude → ✂ utm_source → @agent → Chrome · Sandbox ▸</pre>

If the agent names an intent, or you ask it to use your work profile, that still wins. **Settings › Agents › Sandbox** shows the current binding and can create the intent for you.

## Permissions

**Settings › Agents** has three switches:

| Switch | Default |
| --- | --- |
| Agents can open links | On |
| Agents can propose rules | On |
| Agents can read history | Off |

## Prompts and resources

For MCP clients that support them:

- **Prompts:** `explain_link` and `suggest_rule`.
- **Resources:** `ferry://config`, your `ferry.toml` as text, read-only; and `ferry://schema/trace`, the JSON Schema for traces.

## Errors an agent sees

Errors carry a stable code alongside the message, so an agent can react sensibly:

| Code | When |
| --- | --- |
| `invalid_scheme` | The link isn't `http` or `https` |
| `rate_limited` | Too many links opened too quickly |
| `disabled` | You switched that ability off |
| `invalid_rule`, `duplicate_rule`, `duplicate_proposal` | A proposal was refused |
| `config_missing`, `config_invalid` | `ferry.toml` can't be used |
| `app_unreachable` | The Ferry app isn't running and didn't start |
