# Amp

> Set up the Comity plugin and MCP server for Amp.

Amp has no command-hook config, so Comity integrates through an Amp plugin in `.amp/plugins/`, which forwards Amp's events to `comity hook`, and a workspace MCP server in `.amp/settings.json`.

## Set up

```sh
cd your-repo
comity init --tools amp
git add .amp/plugins/comity.ts .amp/settings.json
git commit -m "Set up Comity for Amp"
```

Start `amp` in the repo and approve the workspace MCP server `comity` when Amp asks (workspace servers need approval once). Run `plugins: list` from the command palette (Ctrl+O) to confirm the plugin loaded. There is no token in the repo: `comity login` is enough.

## What init writes

### `.amp/plugins/comity.ts`

The bridge plugin (first line `// comity-amp-bridge v1 (comity hook)`). It:

- reports `session.start`, every prompt (`agent.start`), `tool.call`, `tool.result` and `agent.end`;
- uses Amp's own helpers to find shell commands and modified files, so every edit or shell tool is covered whatever its name;
- answers a denied call with `reject-and-continue` and Comity's reason, so the agent sees why and keeps going;
- adds the session briefing and prompt context to the prompt (hidden from the transcript), and appends post-tool context to the tool result;
- runs `comity hook --tool amp` per event and allows after 5 seconds or when the CLI is missing.

The file holds no token and no machine path; re-running init rewrites it and `comity doctor` warns when it is from another CLI version.

### `.amp/settings.json`

```json
{
  "amp.mcpServers": {
    "comity": {
      "command": "node",
      "args": ["-e", "<launcher>", "mcp"]
    }
  }
}
```

Amp starts `comity mcp`, a local proxy to the Comity server that authenticates with your `comity login` (or `COMITY_TOKEN`). The entry is the same on every OS, so the committed file never changes between teammates; it needs Node on `PATH` (the CLI needs it anyway). `<launcher>` stands for a one-line Node script that starts `comity mcp` through your shell, so it finds the npm `comity` shim on every OS. Your other settings are kept.

## Verify

```sh
comity doctor
```

Expect `amp plugin  .amp/plugins/comity.ts is current` and `amp mcp  comity server in .amp/settings.json`.

## Limits

- Amp has no session-end event; Comity closes idle sessions on its own.
- In remote orbs the plugin runs on the orb: install and log in the `comity` CLI there, or hooks allow silently.
